sfmc-fuelsdk-ruby 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/Gemfile +3 -3
  4. data/Gemfile.lock +92 -90
  5. data/Guardfile +8 -8
  6. data/LICENSE.md +13 -13
  7. data/README.md +166 -143
  8. data/Rakefile +1 -1
  9. data/lib/marketingcloudsdk.rb +74 -74
  10. data/lib/marketingcloudsdk/client.rb +348 -296
  11. data/lib/marketingcloudsdk/http_request.rb +118 -118
  12. data/lib/marketingcloudsdk/objects.rb +757 -757
  13. data/lib/marketingcloudsdk/rest.rb +118 -118
  14. data/lib/marketingcloudsdk/soap.rb +296 -282
  15. data/lib/marketingcloudsdk/targeting.rb +99 -99
  16. data/lib/marketingcloudsdk/utils.rb +47 -47
  17. data/lib/marketingcloudsdk/version.rb +39 -39
  18. data/lib/new.rb +1240 -1240
  19. data/marketingcloudsdk.gemspec +30 -30
  20. data/samples/sample-AddSubscriberToList.rb +56 -56
  21. data/samples/sample-CreateAndStartDataExtensionImport.rb +29 -29
  22. data/samples/sample-CreateAndStartListImport.rb +27 -27
  23. data/samples/sample-CreateContentAreas.rb +48 -48
  24. data/samples/sample-CreateDataExtensions.rb +54 -54
  25. data/samples/sample-CreateProfileAttributes.rb +48 -48
  26. data/samples/sample-SendEmailToDataExtension.rb +23 -23
  27. data/samples/sample-SendEmailToList.rb +23 -23
  28. data/samples/sample-SendTriggeredSends.rb +30 -30
  29. data/samples/sample-bounceevent.rb +70 -70
  30. data/samples/sample-campaign.rb +211 -211
  31. data/samples/sample-clickevent.rb +71 -71
  32. data/samples/sample-contentarea.rb +122 -122
  33. data/samples/sample-dataextension.rb +209 -209
  34. data/samples/sample-directverb.rb +54 -54
  35. data/samples/sample-email.rb +122 -122
  36. data/samples/sample-email.senddefinition.rb +134 -134
  37. data/samples/sample-folder.rb +143 -143
  38. data/samples/sample-import.rb +103 -103
  39. data/samples/sample-list.rb +105 -105
  40. data/samples/sample-list.subscriber.rb +97 -97
  41. data/samples/sample-openevent.rb +70 -70
  42. data/samples/sample-profileattribute.rb +56 -56
  43. data/samples/sample-sentevent.rb +70 -70
  44. data/samples/sample-subscriber.rb +135 -135
  45. data/samples/sample-triggeredsend.rb +129 -129
  46. data/samples/sample-unsubevent.rb +72 -72
  47. data/samples/sample_helper.rb.template +10 -10
  48. data/spec/client_spec.rb +218 -218
  49. data/spec/default_values_fallback_spec.rb +30 -30
  50. data/spec/helper_funcs_spec.rb +11 -11
  51. data/spec/http_request_spec.rb +61 -61
  52. data/spec/objects_helper_spec.rb +32 -32
  53. data/spec/objects_spec.rb +484 -484
  54. data/spec/rest_spec.rb +48 -48
  55. data/spec/soap_spec.rb +140 -140
  56. data/spec/spec_helper.rb +14 -14
  57. data/spec/targeting_spec.rb +44 -44
  58. metadata +9 -9
data/spec/rest_spec.rb CHANGED
@@ -1,48 +1,48 @@
1
- require 'spec_helper'
2
- describe MarketingCloudSDK::Rest do
3
- let(:client) { MarketingCloudSDK::Client.new }
4
-
5
- subject { client }
6
- it { should respond_to(:rest_get) }
7
- it { should respond_to(:rest_client) }
8
- it { should respond_to(:complete_url) }
9
-
10
- describe '#complete_url' do
11
- it 'raises an exception when identities are missing' do
12
- expect { client.complete_url "some_url/%{parent}/%{child}", {parent: 1} }.to raise_exception 'key{child} not found to complete some_url/%{parent}/%{child}'
13
- end
14
-
15
- it 'returns url with all identities replaced' do
16
- expect( client.complete_url "some_url/%{parent}/%{child}", {:parent => 1, :child => 2} ).to eq 'some_url/1/2'
17
- end
18
-
19
- it 'handles identities with string keys' do
20
- expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> 2} ).to eq 'some_url/1/2'
21
- end
22
-
23
- it 'treats empty values as optional keys' do
24
- expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> ''} ).to eq 'some_url/1'
25
- end
26
-
27
- it 'handles extra keys' do
28
- expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq 'some_url/1'
29
- end
30
- end
31
-
32
- describe '#get_url_properties' do
33
- it 'returns hash of properties in format string' do
34
- expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq({'parent' => 1, 'child' => ''})
35
- end
36
-
37
- it 'handles missing url properties' do
38
- expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'other' => 1} ).to eq({'parent' => 1})
39
- end
40
-
41
- it 'filters url properties from properties leaving query params' do
42
- properties = {'parent'=> 1, 'other' => 1}
43
- client.get_url_properties "some_url/%{parent}/%{child}", properties
44
- expect(properties).to eq 'other' => 1
45
- end
46
- end
47
-
48
- end
1
+ require 'spec_helper'
2
+ describe MarketingCloudSDK::Rest do
3
+ let(:client) { MarketingCloudSDK::Client.new }
4
+
5
+ subject { client }
6
+ it { should respond_to(:rest_get) }
7
+ it { should respond_to(:rest_client) }
8
+ it { should respond_to(:complete_url) }
9
+
10
+ describe '#complete_url' do
11
+ it 'raises an exception when identities are missing' do
12
+ expect { client.complete_url "some_url/%{parent}/%{child}", {parent: 1} }.to raise_exception 'key{child} not found to complete some_url/%{parent}/%{child}'
13
+ end
14
+
15
+ it 'returns url with all identities replaced' do
16
+ expect( client.complete_url "some_url/%{parent}/%{child}", {:parent => 1, :child => 2} ).to eq 'some_url/1/2'
17
+ end
18
+
19
+ it 'handles identities with string keys' do
20
+ expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> 2} ).to eq 'some_url/1/2'
21
+ end
22
+
23
+ it 'treats empty values as optional keys' do
24
+ expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> ''} ).to eq 'some_url/1'
25
+ end
26
+
27
+ it 'handles extra keys' do
28
+ expect( client.complete_url "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq 'some_url/1'
29
+ end
30
+ end
31
+
32
+ describe '#get_url_properties' do
33
+ it 'returns hash of properties in format string' do
34
+ expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'child'=> '', 'other' => 1} ).to eq({'parent' => 1, 'child' => ''})
35
+ end
36
+
37
+ it 'handles missing url properties' do
38
+ expect( client.get_url_properties "some_url/%{parent}/%{child}", {'parent'=> 1, 'other' => 1} ).to eq({'parent' => 1})
39
+ end
40
+
41
+ it 'filters url properties from properties leaving query params' do
42
+ properties = {'parent'=> 1, 'other' => 1}
43
+ client.get_url_properties "some_url/%{parent}/%{child}", properties
44
+ expect(properties).to eq 'other' => 1
45
+ end
46
+ end
47
+
48
+ end
data/spec/soap_spec.rb CHANGED
@@ -1,140 +1,140 @@
1
- require 'spec_helper'
2
-
3
- describe MarketingCloudSDK::Soap do
4
-
5
- let(:client) { MarketingCloudSDK::Client.new }
6
-
7
- subject { client }
8
-
9
- it { should respond_to(:soap_get) }
10
- it { should respond_to(:soap_post) }
11
- it { should respond_to(:soap_patch) }
12
- it { should respond_to(:soap_delete) }
13
- it { should respond_to(:soap_describe) }
14
-
15
- it { should respond_to(:header) }
16
- it { should_not respond_to(:header=) }
17
-
18
- it { should respond_to(:wsdl) }
19
- it { should respond_to(:wsdl=) }
20
-
21
- it { should respond_to(:endpoint) }
22
- it { should_not respond_to(:endpoint=) }
23
-
24
- it { should respond_to(:soap_client) }
25
-
26
- it { should respond_to(:package_name) }
27
- it { should respond_to(:package_name=) }
28
-
29
- it { should respond_to(:package_folders) }
30
- it { should respond_to(:package_folders=) }
31
-
32
- its(:debug) { should be false }
33
- its(:wsdl) { should eq 'https://webservice.exacttarget.com/etframework.wsdl' }
34
-
35
- describe '#header' do
36
- it 'raises an exception when internal_token is missing' do
37
- expect { client.header }.to raise_exception 'Require legacy token for soap header'
38
- end
39
-
40
- it 'returns header hash' do
41
- client.internal_token = 'innerspace'
42
- expect(client.header).to eq(
43
- {
44
- 'oAuth' => { 'oAuthToken' => 'innerspace' },
45
- :attributes! => {
46
- 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }
47
- }
48
- }
49
- )
50
- end
51
- end
52
-
53
- describe 'requests' do
54
- subject {
55
- client.stub(:soap_request) do |action, message|
56
- [action, message]
57
- end
58
- client
59
- }
60
-
61
- it '#soap_describe calls client with :describe and DescribeRequests message' do
62
- expect(subject.soap_describe 'Subscriber').to eq([:describe,
63
- {'DescribeRequests' => {'ObjectDefinitionRequest' => {'ObjectType' => 'Subscriber' }}}])
64
- end
65
-
66
- describe '#soap_post' do
67
- subject {
68
- client.stub(:soap_request) do |action, message|
69
- [action, message]
70
- end
71
-
72
- client.stub_chain(:soap_describe,:editable)
73
- .and_return(['First Name', 'Last Name', 'Gender'])
74
- client
75
- }
76
- it 'formats soap :create message for single object' do
77
- expect(subject.soap_post 'Subscriber', 'EmailAddress' => 'test@fuelsdk.com' ).to eq([:create,
78
- {
79
- 'Objects' => {'EmailAddress' => 'test@fuelsdk.com'},
80
- :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
81
- }])
82
- end
83
-
84
- it 'formats soap :create message for multiple objects' do
85
- expect(subject.soap_post 'Subscriber', [{'EmailAddress' => 'first@fuelsdk.com'}, {'EmailAddress' => 'second@fuelsdk.com'}] ).to eq([:create,
86
- {
87
- 'Objects' => [{'EmailAddress' => 'first@fuelsdk.com'}, {'EmailAddress' => 'second@fuelsdk.com'}],
88
- :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
89
- }])
90
- end
91
-
92
- it 'formats soap :create message for single object with an attribute' do
93
- expect(subject.soap_post 'Subscriber', {'EmailAddress' => 'test@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}]}).to eq([:create,
94
- {
95
- 'Objects' => {
96
- 'EmailAddress' => 'test@fuelsdk.com',
97
- 'Attributes' => [{'Name' => 'First Name', 'Value' => 'first'}],
98
- },
99
- :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
100
- }])
101
- end
102
-
103
- it 'formats soap :create message for single object with multiple attributes' do
104
- expect(subject.soap_post 'Subscriber', {'EmailAddress' => 'test@fuelsdk.com',
105
- 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]}).to eq([:create,
106
- {
107
- 'Objects' => {
108
- 'EmailAddress' => 'test@fuelsdk.com',
109
- 'Attributes' => [
110
- {'Name' => 'First Name', 'Value' => 'first'},
111
- {'Name' => 'Last Name', 'Value' => 'subscriber'},
112
- ],
113
- },
114
- :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
115
- }])
116
- end
117
-
118
- it 'formats soap :create message for multiple objects with multiple attributes' do
119
- expect(subject.soap_post 'Subscriber', [{'EmailAddress' => 'first@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]},
120
- {'EmailAddress' => 'second@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'second'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]}]).to eq([:create,
121
- {
122
- 'Objects' => [
123
- {'EmailAddress' => 'first@fuelsdk.com',
124
- 'Attributes' => [
125
- {'Name' => 'First Name', 'Value' => 'first'},
126
- {'Name' => 'Last Name', 'Value' => 'subscriber'},
127
- ]
128
- },
129
- {'EmailAddress' => 'second@fuelsdk.com',
130
- 'Attributes' => [
131
- {'Name' => 'First Name', 'Value' => 'second'},
132
- {'Name' => 'Last Name', 'Value' => 'subscriber'},
133
- ]
134
- }],
135
- :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
136
- }])
137
- end
138
- end
139
- end
140
- end
1
+ require 'spec_helper'
2
+
3
+ describe MarketingCloudSDK::Soap do
4
+
5
+ let(:client) { MarketingCloudSDK::Client.new }
6
+
7
+ subject { client }
8
+
9
+ it { should respond_to(:soap_get) }
10
+ it { should respond_to(:soap_post) }
11
+ it { should respond_to(:soap_patch) }
12
+ it { should respond_to(:soap_delete) }
13
+ it { should respond_to(:soap_describe) }
14
+
15
+ it { should respond_to(:header) }
16
+ it { should_not respond_to(:header=) }
17
+
18
+ it { should respond_to(:wsdl) }
19
+ it { should respond_to(:wsdl=) }
20
+
21
+ it { should respond_to(:endpoint) }
22
+ it { should_not respond_to(:endpoint=) }
23
+
24
+ it { should respond_to(:soap_client) }
25
+
26
+ it { should respond_to(:package_name) }
27
+ it { should respond_to(:package_name=) }
28
+
29
+ it { should respond_to(:package_folders) }
30
+ it { should respond_to(:package_folders=) }
31
+
32
+ its(:debug) { should be false }
33
+ its(:wsdl) { should eq 'https://webservice.exacttarget.com/etframework.wsdl' }
34
+
35
+ describe '#header' do
36
+ it 'raises an exception when internal_token is missing' do
37
+ expect { client.header }.to raise_exception 'Require legacy token for soap header'
38
+ end
39
+
40
+ it 'returns header hash' do
41
+ client.internal_token = 'innerspace'
42
+ expect(client.header).to eq(
43
+ {
44
+ 'oAuth' => { 'oAuthToken' => 'innerspace' },
45
+ :attributes! => {
46
+ 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }
47
+ }
48
+ }
49
+ )
50
+ end
51
+ end
52
+
53
+ describe 'requests' do
54
+ subject {
55
+ client.stub(:soap_request) do |action, message|
56
+ [action, message]
57
+ end
58
+ client
59
+ }
60
+
61
+ it '#soap_describe calls client with :describe and DescribeRequests message' do
62
+ expect(subject.soap_describe 'Subscriber').to eq([:describe,
63
+ {'DescribeRequests' => {'ObjectDefinitionRequest' => {'ObjectType' => 'Subscriber' }}}])
64
+ end
65
+
66
+ describe '#soap_post' do
67
+ subject {
68
+ client.stub(:soap_request) do |action, message|
69
+ [action, message]
70
+ end
71
+
72
+ client.stub_chain(:soap_describe,:editable)
73
+ .and_return(['First Name', 'Last Name', 'Gender'])
74
+ client
75
+ }
76
+ it 'formats soap :create message for single object' do
77
+ expect(subject.soap_post 'Subscriber', 'EmailAddress' => 'test@fuelsdk.com' ).to eq([:create,
78
+ {
79
+ 'Objects' => {'EmailAddress' => 'test@fuelsdk.com'},
80
+ :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
81
+ }])
82
+ end
83
+
84
+ it 'formats soap :create message for multiple objects' do
85
+ expect(subject.soap_post 'Subscriber', [{'EmailAddress' => 'first@fuelsdk.com'}, {'EmailAddress' => 'second@fuelsdk.com'}] ).to eq([:create,
86
+ {
87
+ 'Objects' => [{'EmailAddress' => 'first@fuelsdk.com'}, {'EmailAddress' => 'second@fuelsdk.com'}],
88
+ :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
89
+ }])
90
+ end
91
+
92
+ it 'formats soap :create message for single object with an attribute' do
93
+ expect(subject.soap_post 'Subscriber', {'EmailAddress' => 'test@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}]}).to eq([:create,
94
+ {
95
+ 'Objects' => {
96
+ 'EmailAddress' => 'test@fuelsdk.com',
97
+ 'Attributes' => [{'Name' => 'First Name', 'Value' => 'first'}],
98
+ },
99
+ :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
100
+ }])
101
+ end
102
+
103
+ it 'formats soap :create message for single object with multiple attributes' do
104
+ expect(subject.soap_post 'Subscriber', {'EmailAddress' => 'test@fuelsdk.com',
105
+ 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]}).to eq([:create,
106
+ {
107
+ 'Objects' => {
108
+ 'EmailAddress' => 'test@fuelsdk.com',
109
+ 'Attributes' => [
110
+ {'Name' => 'First Name', 'Value' => 'first'},
111
+ {'Name' => 'Last Name', 'Value' => 'subscriber'},
112
+ ],
113
+ },
114
+ :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
115
+ }])
116
+ end
117
+
118
+ it 'formats soap :create message for multiple objects with multiple attributes' do
119
+ expect(subject.soap_post 'Subscriber', [{'EmailAddress' => 'first@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]},
120
+ {'EmailAddress' => 'second@fuelsdk.com', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'second'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]}]).to eq([:create,
121
+ {
122
+ 'Objects' => [
123
+ {'EmailAddress' => 'first@fuelsdk.com',
124
+ 'Attributes' => [
125
+ {'Name' => 'First Name', 'Value' => 'first'},
126
+ {'Name' => 'Last Name', 'Value' => 'subscriber'},
127
+ ]
128
+ },
129
+ {'EmailAddress' => 'second@fuelsdk.com',
130
+ 'Attributes' => [
131
+ {'Name' => 'First Name', 'Value' => 'second'},
132
+ {'Name' => 'Last Name', 'Value' => 'subscriber'},
133
+ ]
134
+ }],
135
+ :attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
136
+ }])
137
+ end
138
+ end
139
+ end
140
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,14 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
-
4
- require 'marketingcloudsdk'
5
-
6
- RSpec.configure do |config|
7
- config.mock_with :rspec
8
-
9
- # Use color in STDOUT
10
- config.color = true
11
-
12
- # Use the specified formatter
13
- config.formatter = :documentation
14
- end
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'marketingcloudsdk'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+
9
+ # Use color in STDOUT
10
+ config.color = true
11
+
12
+ # Use the specified formatter
13
+ config.formatter = :documentation
14
+ end
@@ -1,44 +1,44 @@
1
- require 'spec_helper'
2
-
3
- describe MarketingCloudSDK::Targeting do
4
-
5
- subject { Class.new.new.extend(MarketingCloudSDK::Targeting) }
6
-
7
- it { should respond_to(:endpoint) }
8
- it { should_not respond_to(:endpoint=) }
9
- it { should_not respond_to(:get_soap_endpoint) }
10
- it { should respond_to(:get) }
11
- it { should respond_to(:post) }
12
- it { should respond_to(:patch) }
13
- it { should respond_to(:delete) }
14
- it { should respond_to(:access_token) }
15
-
16
- describe '#get_soap_endpoint' do
17
- let(:client) { c = Class.new.new.extend(MarketingCloudSDK::Targeting)
18
- c.stub(:base_api_url).and_return('https://www.exacttargetapis.com')
19
- c.stub(:access_token).and_return('open_sesame')
20
- c.stub(:get_soap_endpoint_from_file).and_return(nil)
21
- c.stub(:set_soap_endpoint_to_file).and_return(nil)
22
- c.stub(:get)
23
- .with('https://www.exacttargetapis.com/platform/v1/endpoints/soap',{'access_token'=>'open_sesame'})
24
- .and_return({'url' => 'S#.authentication.target'})
25
- c
26
- }
27
- it 'sets @endpoint' do
28
- client.send(:get_soap_endpoint)
29
- expect(client.endpoint).to eq 'S#.authentication.target'
30
- end
31
- end
32
-
33
- describe '#endpoint' do
34
- let(:client) { c = Class.new.new.extend(MarketingCloudSDK::Targeting)
35
- c.stub(:base_api_url).and_return('bogus url')
36
- c.stub(:get).and_return({'url' => 'S#.authentication.target'})
37
- c
38
- }
39
-
40
- it 'calls get_soap_endpoint to find target' do
41
- expect(client.endpoint).to eq 'S#.authentication.target'
42
- end
43
- end
44
- end
1
+ require 'spec_helper'
2
+
3
+ describe MarketingCloudSDK::Targeting do
4
+
5
+ subject { Class.new.new.extend(MarketingCloudSDK::Targeting) }
6
+
7
+ it { should respond_to(:endpoint) }
8
+ it { should_not respond_to(:endpoint=) }
9
+ it { should_not respond_to(:get_soap_endpoint) }
10
+ it { should respond_to(:get) }
11
+ it { should respond_to(:post) }
12
+ it { should respond_to(:patch) }
13
+ it { should respond_to(:delete) }
14
+ it { should respond_to(:access_token) }
15
+
16
+ describe '#get_soap_endpoint' do
17
+ let(:client) { c = Class.new.new.extend(MarketingCloudSDK::Targeting)
18
+ c.stub(:base_api_url).and_return('https://www.exacttargetapis.com')
19
+ c.stub(:access_token).and_return('open_sesame')
20
+ c.stub(:get_soap_endpoint_from_file).and_return(nil)
21
+ c.stub(:set_soap_endpoint_to_file).and_return(nil)
22
+ c.stub(:get)
23
+ .with('https://www.exacttargetapis.com/platform/v1/endpoints/soap',{'access_token'=>'open_sesame'})
24
+ .and_return({'url' => 'S#.authentication.target'})
25
+ c
26
+ }
27
+ it 'sets @endpoint' do
28
+ client.send(:get_soap_endpoint)
29
+ expect(client.endpoint).to eq 'S#.authentication.target'
30
+ end
31
+ end
32
+
33
+ describe '#endpoint' do
34
+ let(:client) { c = Class.new.new.extend(MarketingCloudSDK::Targeting)
35
+ c.stub(:base_api_url).and_return('bogus url')
36
+ c.stub(:get).and_return({'url' => 'S#.authentication.target'})
37
+ c
38
+ }
39
+
40
+ it 'calls get_soap_endpoint to find target' do
41
+ expect(client.endpoint).to eq 'S#.authentication.target'
42
+ end
43
+ end
44
+ end