Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
sfmc-fuelsdk-ruby (1.3.1)
sfmc-fuelsdk-ruby (2.0.0)
json (>= 2.2.0)
jwt (>= 2.1.0)
savon (>= 2.12.1)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ ExactTarget Fuel SDK / SalesforceMarektingCloudSDK for Ruby
## Overview ##
The Fuel SDK for Ruby provides easy access to ExactTarget's Fuel API Family services, including a collection of REST APIs and a SOAP API. These APIs provide access to ExactTarget functionality via common collection types such as array/hash.

## New Features in Version 2.0.0 ##

- @JadeDickinson added support for tenant-specific endpoints.
- To use this feature, copy config/endpoints.yml from this Gem to ./config/endpoints.yml in your application using FuelSDK-Ruby.
- You must then replace the placeholder values with your tenant-specific endpoints - see the following links for more details:
- [SOAP API](https://help.salesforce.com/s/articleView?id=000356497&type=1)
- [REST API](https://help.salesforce.com/s/articleView?id=000356498&type=1)

## New Features in Version 1.3.1 ##
- **Updated below packages to latest version**
- savon: ">= 2.12.1"
Expand Down
4 changes: 4 additions & 0 deletions config/endpoints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
base_api_url: 'https://placeholder.rest.marketingcloudapis.com'
request_token_url: 'https://placeholder.rest.marketingcloudapis.com/v1/requestToken'
soap_wsdl_endpoint: 'https://placeholder.soap.marketingcloudapis.com/etframework.wsdl'
soap_service_endpoint: 'https://placeholder.soap.marketingcloudapis.com/Service.asmx'
7 changes: 4 additions & 3 deletions lib/marketingcloudsdk/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
=end

require 'securerandom'
require_relative './exact_target_endpoints'
module MarketingCloudSDK
class Response
# not doing accessor so user, can't update these values from response.
Expand Down Expand Up @@ -103,7 +104,7 @@ def initialize(params={}, debug=false)
self.id = client_config["id"]
self.secret = client_config["secret"]
self.signature = client_config["signature"]
self.base_api_url = !(client_config["base_api_url"].to_s.strip.empty?) ? client_config["base_api_url"] : 'https://www.exacttargetapis.com'
self.base_api_url = !(client_config["base_api_url"].to_s.strip.empty?) ? client_config["base_api_url"] : ExactTargetEndpoints.base_api_url
self.request_token_url = client_config["request_token_url"]
self.soap_endpoint = client_config["soap_endpoint"]
self.use_oAuth2_authentication = client_config["use_oAuth2_authentication"]
Expand All @@ -116,14 +117,14 @@ def initialize(params={}, debug=false)

# Set a default value in case no 'client' params is sent
if (!self.base_api_url)
self.base_api_url = 'https://www.exacttargetapis.com'
self.base_api_url = ExactTargetEndpoints.base_api_url
end

if (self.request_token_url.to_s.strip.empty?)
if(use_oAuth2_authentication == true)
raise 'request_token_url (Auth TSE) is mandatory when using OAuth2 authentication'
else
self.request_token_url = 'https://auth.exacttargetapis.com/v1/requestToken'
self.request_token_url = ExactTargetEndpoints.request_token_url
end
end

Expand Down
25 changes: 25 additions & 0 deletions lib/marketingcloudsdk/exact_target_endpoints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module MarketingCloudSDK
class ExactTargetEndpoints

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't Exact target name "deprecated"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, think I'll rename TenantSpecificEndpoints

def self.config
YAML.load_file(
File.join('config', 'endpoints.yml')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe consider naming this marketing_cloud_endpoints or similar?
it's possible that applications that use this gem also use other 3rd parties, so just "endpoints" will not be specific enough

)
end

def self.base_api_url
@base_api_url ||= config['base_api_url']
end

def self.request_token_url
@request_token_url ||= config['request_token_url']
end

def self.soap_wsdl_endpoint
@soap_wsdl_endpoint ||= config['soap_wsdl_endpoint']
end

def self.soap_service_endpoint
@soap_service_endpoint ||= config['soap_service_endpoint']
end
end
end
3 changes: 2 additions & 1 deletion lib/marketingcloudsdk/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def unpack_rslts raw
end
end

require_relative './exact_target_endpoints'
module Soap
attr_accessor :wsdl, :debug#, :internal_token

Expand All @@ -140,7 +141,7 @@ def debug
end

def wsdl
@wsdl ||= 'https://webservice.exacttarget.com/etframework.wsdl'
@wsdl ||= ExactTargetEndpoints.soap_wsdl_endpoint
end

def soap_client
Expand Down
2 changes: 1 addition & 1 deletion lib/marketingcloudsdk/targeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ def get_soap_endpoint
@endpoint = response['url']
set_soap_endpoint_to_file @endpoint
rescue => e
@endpoint = 'https://webservice.exacttarget.com/Service.asmx'
@endpoint = ExactTargetEndpoints.soap_service_endpoint
end
end
2 changes: 1 addition & 1 deletion lib/marketingcloudsdk/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
=end

module MarketingCloudSDK
VERSION = "1.3.1"
VERSION = "2.0.0"
end
10 changes: 5 additions & 5 deletions lib/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
require 'json'
require 'yaml'
require 'jwt'

require_relative './marketing_cloud_sdk/exact_target_endpoints'

def indifferent_access key, hash
hash[key.to_sym] || hash[key.to_s]
Expand Down Expand Up @@ -227,7 +227,7 @@ def refreshToken(force = nil)
#If we don't already have a token or the token expires within 5 min(300 seconds), get one
if ((@authToken.nil? || Time.new + 300 > @authTokenExpiration) || force) then
begin
uri = URI.parse("https://auth.exacttargetapis.com/v1/requestToken?legacy=1")
uri = URI.parse("#{MarketingCloudSDK::ExactTargetEndpoints.base_api_url}/v1/requestToken?legacy=1")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
Expand Down Expand Up @@ -318,7 +318,7 @@ def CreateDataExtensions(dataExtensionDefinitions)
protected
def determineStack()
begin
uri = URI.parse("https://www.exacttargetapis.com/platform/v1/endpoints/soap?access_token=" + @authToken)
uri = URI.parse("#{MarketingCloudSDK::ExactTargetEndpoints.base_api_url}/platform/v1/endpoints/soap?access_token=" + @authToken)
http = Net::HTTP.new(uri.host, uri.port)

http.use_ssl = true
Expand Down Expand Up @@ -908,15 +908,15 @@ def initialize(authStub, endpoint)
class ET_Campaign < ET_CUDSupportRest
def initialize
super
@endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns/{id}'
@endpoint = "#{MarketingCloudSDK::ExactTargetEndpoints.base_api_url}/hub/v1/campaigns/{id}"
@urlProps = ["id"]
@urlPropsRequired = []
end

class Asset < ET_CUDSupportRest
def initialize
super
@endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns/{id}/assets/{assetId}'
@endpoint = "#{MarketingCloudSDK::ExactTargetEndpoints.base_api_url}/hub/v1/campaigns/{id}/assets/{assetId}"
@urlProps = ["id", "assetId"]
@urlPropsRequired = ["id"]
end
Expand Down
5 changes: 3 additions & 2 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper.rb'
require 'public_or_web_integration_credentials'
require './lib/marketingcloudsdk/exact_target_endpoints'

def get_test_stub
{'client' => {
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_test_stub
it 'with wsdl set to default value if not set in params' do
client = MarketingCloudSDK::Client.new(get_test_stub)

expect(client.wsdl).to eq 'https://webservice.exacttarget.com/etframework.wsdl'
expect(client.wsdl).to eq 'https://placeholder.soap.marketingcloudapis.com/etframework.wsdl'
end

it 'with application_type set to \'server\' if application_type is not set in params' do
Expand Down Expand Up @@ -168,7 +169,7 @@ def get_test_stub
end

it'#wsdl returns default wsdl' do
expect(client.wsdl).to eq 'https://webservice.exacttarget.com/etframework.wsdl'
expect(client.wsdl).to eq 'https://placeholder.soap.marketingcloudapis.com/etframework.wsdl'
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/default_values_fallback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
'base_api_url' => ''}

it 'Should use REST endpoint default value if base_api_url endpoint is an empty string in config' do
expect(client1.base_api_url).to eq 'https://www.exacttargetapis.com'
expect(client1.base_api_url).to eq 'https://placeholder.rest.marketingcloudapis.com'
end

it 'Should use Auth endpoint default value if request_token_url attribute is not in config' do
expect(client1.request_token_url).to eq 'https://auth.exacttargetapis.com/v1/requestToken'
expect(client1.request_token_url).to eq 'https://placeholder.rest.marketingcloudapis.com/v1/requestToken'
end
end

Expand All @@ -22,7 +22,7 @@
'base_api_url' => ' '}

it 'Should use REST endpoint default value if REST endpoint is a blank string in config' do
expect(client2.base_api_url).to eq 'https://www.exacttargetapis.com'
expect(client2.base_api_url).to eq 'https://placeholder.rest.marketingcloudapis.com'
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/soap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
it { should respond_to(:package_folders=) }

its(:debug) { should be false }
its(:wsdl) { should eq 'https://webservice.exacttarget.com/etframework.wsdl' }
its(:wsdl) { should eq 'https://placeholder.soap.marketingcloudapis.com/etframework.wsdl' }

describe '#header' do
it 'raises an exception when internal_token is missing' do
Expand Down
5 changes: 3 additions & 2 deletions spec/targeting_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require './lib/marketingcloudsdk/exact_target_endpoints'

describe MarketingCloudSDK::Targeting do

Expand All @@ -15,12 +16,12 @@

describe '#get_soap_endpoint' do
let(:client) { c = Class.new.new.extend(MarketingCloudSDK::Targeting)
c.stub(:base_api_url).and_return('https://www.exacttargetapis.com')
c.stub(:base_api_url).and_return(MarketingCloudSDK::ExactTargetEndpoints.base_api_url)
c.stub(:access_token).and_return('open_sesame')
c.stub(:get_soap_endpoint_from_file).and_return(nil)
c.stub(:set_soap_endpoint_to_file).and_return(nil)
c.stub(:get)
.with('https://www.exacttargetapis.com/platform/v1/endpoints/soap',{'access_token'=>'open_sesame'})
.with("#{MarketingCloudSDK::ExactTargetEndpoints.base_api_url}/platform/v1/endpoints/soap",{'access_token'=>'open_sesame'})
.and_return({'url' => 'S#.authentication.target'})
c
}
Expand Down