responsys-api 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/README.md +82 -10
- data/lib/responsys/api/all.rb +17 -0
- data/lib/responsys/api/campaign.rb +26 -0
- data/lib/responsys/api/client.rb +70 -0
- data/lib/responsys/api/folder.rb +25 -0
- data/lib/responsys/api/list.rb +39 -0
- data/lib/responsys/api/object/all.rb +11 -0
- data/lib/responsys/api/object/email_format.rb +23 -0
- data/lib/responsys/api/object/field.rb +20 -0
- data/lib/responsys/api/object/field_type.rb +23 -0
- data/lib/responsys/api/object/interact_object.rb +18 -0
- data/lib/responsys/api/object/list_merge_rule.rb +41 -0
- data/lib/responsys/api/object/optional_data.rb +23 -0
- data/lib/responsys/api/object/query_column.rb +23 -0
- data/lib/responsys/api/object/recipient.rb +30 -0
- data/lib/responsys/api/object/recipient_data.rb +21 -0
- data/lib/responsys/api/object/record.rb +19 -0
- data/lib/responsys/api/object/record_data.rb +31 -0
- data/lib/responsys/api/session.rb +30 -0
- data/lib/responsys/api/table.rb +49 -0
- data/lib/responsys/configuration.rb +3 -3
- data/lib/responsys/exceptions/all.rb +1 -0
- data/lib/responsys/exceptions/parameter_exception.rb +7 -0
- data/lib/responsys/helper.rb +78 -2
- data/lib/responsys/i18n/en.yml +20 -0
- data/lib/responsys/member.rb +80 -0
- data/lib/responsys_api.rb +11 -4
- data/responsys-api.gemspec +12 -9
- data/spec/api/campaign_spec.rb +27 -0
- data/spec/api/client_spec.rb +107 -0
- data/spec/api/list_spec.rb +71 -0
- data/spec/api/object/recipient_data_spec.rb +43 -0
- data/spec/api/object/recipient_spec.rb +68 -0
- data/spec/api/object/record_data_spec.rb +28 -0
- data/spec/api/table_spec.rb +111 -0
- data/spec/fixtures/vcr_cassettes/api/campaign/login.yml +940 -0
- data/spec/fixtures/vcr_cassettes/api/client/expired_session.yml +1030 -0
- data/spec/fixtures/vcr_cassettes/api/list/login.yml +982 -0
- data/spec/fixtures/vcr_cassettes/api/list/merge.yml +134 -0
- data/spec/fixtures/vcr_cassettes/api/list/retrieve.yml +46 -0
- data/spec/fixtures/vcr_cassettes/api/list/retrieve_single.yml +133 -0
- data/spec/fixtures/vcr_cassettes/api/list/retrieve_single_single.yml +45 -0
- data/spec/fixtures/vcr_cassettes/api/profile_extension/login.yml +982 -0
- data/spec/fixtures/vcr_cassettes/api/profile_extension/merge_profile_extension_records.yml +46 -0
- data/spec/fixtures/vcr_cassettes/api/profile_extension/retrieve_profile_extension_records.yml +45 -0
- data/spec/fixtures/vcr_cassettes/api/table/create.yml +45 -0
- data/spec/fixtures/vcr_cassettes/api/table/create_with_pk.yml +45 -0
- data/spec/fixtures/vcr_cassettes/api/table/delete.yml +45 -0
- data/spec/fixtures/vcr_cassettes/api/table/delete_with_pk.yml +45 -0
- data/spec/fixtures/vcr_cassettes/member/present1.yml +982 -0
- data/spec/fixtures/vcr_cassettes/member/present2.yml +45 -0
- data/spec/fixtures/vcr_cassettes/member/present3.yml +48 -0
- data/spec/fixtures/vcr_cassettes/member/present4.yml +48 -0
- data/spec/fixtures/vcr_cassettes/member/present5.yml +48 -0
- data/spec/fixtures/vcr_cassettes/member/retrieve_profile_extension.yml +87 -0
- data/spec/member_spec.rb +136 -0
- data/spec/spec_helper.rb +28 -2
- metadata +136 -19
- data/lib/responsys/responsys_api.rb +0 -41
- data/lib/savon/savon_api.rb +0 -22
- data/spec/responsys_api_spec.rb +0 -4
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveListMembers><tns:list><tns:folderName>another_test_folder</tns:folderName><tns:objectName>test_list</tns:objectName></tns:list><tns:queryColumn>RIID</tns:queryColumn><tns:fieldList>EMAIL_PERMISSION_STATUS_</tns:fieldList><tns:idsToRetrieve>1225</tns:idsToRetrieve></tns:retrieveListMembers></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
Cookie:
|
13
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
14
|
+
Soapaction:
|
15
|
+
- ! '"retrieveListMembers"'
|
16
|
+
Content-Type:
|
17
|
+
- text/xml;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '677'
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Content-Length:
|
30
|
+
- '383'
|
31
|
+
Content-Type:
|
32
|
+
- text/xml; charset=UTF-8
|
33
|
+
Date:
|
34
|
+
- Fri, 29 Aug 2014 22:31:03 GMT
|
35
|
+
Server:
|
36
|
+
- Apache
|
37
|
+
Set-Cookie:
|
38
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveListMembersResponse
|
42
|
+
xmlns="urn:ws.rsys.com"><result><recordData><fieldNames>EMAIL_PERMISSION_STATUS_</fieldNames><records><fieldValues>I</fieldValues></records></recordData></result></retrieveListMembersResponse></soapenv:Body></soapenv:Envelope>
|
43
|
+
http_version:
|
44
|
+
recorded_at: Fri, 29 Aug 2014 22:31:03 GMT
|
45
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveListMembers><tns:list><tns:folderName>another_test_folder</tns:folderName><tns:objectName>test_list</tns:objectName></tns:list><tns:queryColumn>EMAIL_ADDRESS</tns:queryColumn><tns:fieldList>EMAIL_PERMISSION_STATUS_</tns:fieldList><tns:idsToRetrieve>thisemailis@notpresent.com</tns:idsToRetrieve></tns:retrieveListMembers></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
Cookie:
|
13
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
14
|
+
Soapaction:
|
15
|
+
- ! '"retrieveListMembers"'
|
16
|
+
Content-Type:
|
17
|
+
- text/xml;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '708'
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 500
|
27
|
+
message: Internal Server Error
|
28
|
+
headers:
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Content-Length:
|
32
|
+
- '462'
|
33
|
+
Content-Type:
|
34
|
+
- text/xml;charset=UTF-8
|
35
|
+
Date:
|
36
|
+
- Fri, 29 Aug 2014 22:31:03 GMT
|
37
|
+
Server:
|
38
|
+
- Apache
|
39
|
+
Set-Cookie:
|
40
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>ListFault</faultstring><detail><ListFault
|
44
|
+
xmlns="urn:fault.ws.rsys.com"><exceptionCode>RECORD_NOT_FOUND</exceptionCode><exceptionMessage>No
|
45
|
+
records found in the list for given ids</exceptionMessage></ListFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
|
46
|
+
http_version:
|
47
|
+
recorded_at: Fri, 29 Aug 2014 22:31:03 GMT
|
48
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveListMembers><tns:list><tns:folderName>another_test_folder</tns:folderName><tns:objectName>test_list</tns:objectName></tns:list><tns:queryColumn>RIID</tns:queryColumn><tns:fieldList>EMAIL_PERMISSION_STATUS_</tns:fieldList><tns:idsToRetrieve>000001</tns:idsToRetrieve></tns:retrieveListMembers></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
Cookie:
|
13
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
14
|
+
Soapaction:
|
15
|
+
- ! '"retrieveListMembers"'
|
16
|
+
Content-Type:
|
17
|
+
- text/xml;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '679'
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 500
|
27
|
+
message: Internal Server Error
|
28
|
+
headers:
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Content-Length:
|
32
|
+
- '462'
|
33
|
+
Content-Type:
|
34
|
+
- text/xml;charset=UTF-8
|
35
|
+
Date:
|
36
|
+
- Fri, 29 Aug 2014 22:31:04 GMT
|
37
|
+
Server:
|
38
|
+
- Apache
|
39
|
+
Set-Cookie:
|
40
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>ListFault</faultstring><detail><ListFault
|
44
|
+
xmlns="urn:fault.ws.rsys.com"><exceptionCode>RECORD_NOT_FOUND</exceptionCode><exceptionMessage>No
|
45
|
+
records found in the list for given ids</exceptionMessage></ListFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
|
46
|
+
http_version:
|
47
|
+
recorded_at: Fri, 29 Aug 2014 22:31:04 GMT
|
48
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveListMembers><tns:list><tns:folderName>another_test_folder</tns:folderName><tns:objectName>test_list</tns:objectName></tns:list><tns:queryColumn>RIID</tns:queryColumn><tns:fieldList>EMAIL_PERMISSION_STATUS_</tns:fieldList><tns:idsToRetrieve>000001</tns:idsToRetrieve></tns:retrieveListMembers></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
Cookie:
|
13
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
14
|
+
Soapaction:
|
15
|
+
- ! '"retrieveListMembers"'
|
16
|
+
Content-Type:
|
17
|
+
- text/xml;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '679'
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 500
|
27
|
+
message: Internal Server Error
|
28
|
+
headers:
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
Content-Length:
|
32
|
+
- '462'
|
33
|
+
Content-Type:
|
34
|
+
- text/xml;charset=UTF-8
|
35
|
+
Date:
|
36
|
+
- Fri, 29 Aug 2014 22:31:04 GMT
|
37
|
+
Server:
|
38
|
+
- Apache
|
39
|
+
Set-Cookie:
|
40
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>ListFault</faultstring><detail><ListFault
|
44
|
+
xmlns="urn:fault.ws.rsys.com"><exceptionCode>RECORD_NOT_FOUND</exceptionCode><exceptionMessage>No
|
45
|
+
records found in the list for given ids</exceptionMessage></ListFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
|
46
|
+
http_version:
|
47
|
+
recorded_at: Fri, 29 Aug 2014 22:31:04 GMT
|
48
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,87 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveProfileExtensionRecords><tns:profileExtension><tns:folderName>demo_folder2</tns:folderName><tns:objectName>customers_extension</tns:objectName></tns:profileExtension><tns:queryColumn>RIID</tns:queryColumn><tns:fieldList>RIID_</tns:fieldList><tns:idsToRetrieve>1125</tns:idsToRetrieve></tns:retrieveProfileExtensionRecords></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
Cookie:
|
13
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
14
|
+
Soapaction:
|
15
|
+
- ! '"retrieveProfileExtensionRecords"'
|
16
|
+
Content-Type:
|
17
|
+
- text/xml;charset=UTF-8
|
18
|
+
Content-Length:
|
19
|
+
- '709'
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Content-Length:
|
30
|
+
- '391'
|
31
|
+
Content-Type:
|
32
|
+
- text/xml; charset=UTF-8
|
33
|
+
Date:
|
34
|
+
- Fri, 29 Aug 2014 22:31:04 GMT
|
35
|
+
Server:
|
36
|
+
- Apache
|
37
|
+
Set-Cookie:
|
38
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveProfileExtensionRecordsResponse
|
42
|
+
xmlns="urn:ws.rsys.com"><result><recordData><fieldNames>RIID_</fieldNames><records><fieldValues>1125</fieldValues></records></recordData></result></retrieveProfileExtensionRecordsResponse></soapenv:Body></soapenv:Envelope>
|
43
|
+
http_version:
|
44
|
+
recorded_at: Fri, 29 Aug 2014 22:31:04 GMT
|
45
|
+
- request:
|
46
|
+
method: post
|
47
|
+
uri: https://wsxxxx.responsys.net/webservices/services/ResponsysWSService
|
48
|
+
body:
|
49
|
+
encoding: US-ASCII
|
50
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
51
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="urn:ws.rsys.com"
|
52
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><sessionHeader><sessionId>bBvxPCXScxL40VhQx6JFG6ziO9</sessionId></sessionHeader></env:Header><env:Body><tns:retrieveProfileExtensionRecords><tns:profileExtension><tns:folderName>demo_folder2</tns:folderName><tns:objectName>customers_extension</tns:objectName></tns:profileExtension><tns:queryColumn>RIID</tns:queryColumn><tns:fieldList>RIID_</tns:fieldList><tns:fieldList>EMAIL_ADDRESS</tns:fieldList><tns:idsToRetrieve>1125</tns:idsToRetrieve></tns:retrieveProfileExtensionRecords></env:Body></env:Envelope>
|
53
|
+
headers:
|
54
|
+
Cookie:
|
55
|
+
- JSESSIONID=EF4D2D3574EA896D10416D6FF9DE184E.ws01-ri5
|
56
|
+
Soapaction:
|
57
|
+
- ! '"retrieveProfileExtensionRecords"'
|
58
|
+
Content-Type:
|
59
|
+
- text/xml;charset=UTF-8
|
60
|
+
Content-Length:
|
61
|
+
- '753'
|
62
|
+
Accept:
|
63
|
+
- ! '*/*'
|
64
|
+
User-Agent:
|
65
|
+
- Ruby
|
66
|
+
response:
|
67
|
+
status:
|
68
|
+
code: 200
|
69
|
+
message: OK
|
70
|
+
headers:
|
71
|
+
Content-Length:
|
72
|
+
- '471'
|
73
|
+
Content-Type:
|
74
|
+
- text/xml; charset=UTF-8
|
75
|
+
Date:
|
76
|
+
- Fri, 29 Aug 2014 22:31:04 GMT
|
77
|
+
Server:
|
78
|
+
- Apache
|
79
|
+
Set-Cookie:
|
80
|
+
- BIGipServerDC2-APIGEE-I5-9051-SSL=3617446922.23331.0000; path=/
|
81
|
+
body:
|
82
|
+
encoding: US-ASCII
|
83
|
+
string: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveProfileExtensionRecordsResponse
|
84
|
+
xmlns="urn:ws.rsys.com"><result><recordData><fieldNames>RIID_</fieldNames><fieldNames>EMAIL_ADDRESS</fieldNames><records><fieldValues>1125</fieldValues><fieldValues>user@email.com</fieldValues></records></recordData></result></retrieveProfileExtensionRecordsResponse></soapenv:Body></soapenv:Envelope>
|
85
|
+
http_version:
|
86
|
+
recorded_at: Fri, 29 Aug 2014 22:31:04 GMT
|
87
|
+
recorded_with: VCR 2.5.0
|
data/spec/member_spec.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "spec_helper.rb"
|
2
|
+
require "responsys/api/client"
|
3
|
+
|
4
|
+
describe Responsys::Member do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@email = "user@email.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
context "New member" do
|
11
|
+
|
12
|
+
xit "should call mergeListMembers" do
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "Subscribing" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@connection = double "connection"
|
21
|
+
|
22
|
+
allow(Responsys::Api::Client).to receive(:instance).and_return(@connection)
|
23
|
+
|
24
|
+
@member = Responsys::Member.new(@email)
|
25
|
+
@list = Responsys::Api::Object::InteractObject.new("list_folder","list_object_name")
|
26
|
+
@query_column = Responsys::Api::Object::QueryColumn.new("EMAIL_ADDRESS")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should check the user is present in the list" do
|
30
|
+
expect(@member).to receive(:present_in_list?).with(@list)
|
31
|
+
|
32
|
+
@member.subscribe(@list)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should check the user has subscribed" do
|
36
|
+
response_expected = { status: "ok", data: [{ EMAIL_PERMISSION_STATUS_: "I" }] }
|
37
|
+
|
38
|
+
allow(@connection).to receive(:retrieve_list_members).with(@list, kind_of(Responsys::Api::Object::QueryColumn), %w(EMAIL_PERMISSION_STATUS_), %W(#{@member.email})).and_return(response_expected)
|
39
|
+
|
40
|
+
expect(@member.subscribed?(@list)).to eq(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "Existing member" do
|
46
|
+
|
47
|
+
before(:all) do
|
48
|
+
@list = Responsys::Api::Object::InteractObject.new("another_test_folder","test_list")
|
49
|
+
@riid = 1225
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be ok, the email is present" do
|
53
|
+
VCR.use_cassette("member/present1") do
|
54
|
+
member_without_riid = Responsys::Member.new(@email)
|
55
|
+
bool = member_without_riid.present_in_list?(@list)
|
56
|
+
|
57
|
+
expect(bool).to eq(true)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be ok, the email and riid is present" do
|
62
|
+
VCR.use_cassette("member/present2") do
|
63
|
+
member_with_riid = Responsys::Member.new(@email, @riid)
|
64
|
+
bool = member_with_riid.present_in_list?(@list)
|
65
|
+
|
66
|
+
expect(bool).to eq(true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should fail, the email is not present" do
|
71
|
+
VCR.use_cassette("member/present3") do
|
72
|
+
member_with_fake_email = Responsys::Member.new("thisemailis@notpresent.com")
|
73
|
+
bool = member_with_fake_email.present_in_list?(@list)
|
74
|
+
|
75
|
+
expect(bool).to eq(false)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should fail, the email is present but not the riid" do
|
80
|
+
VCR.use_cassette("member/present4") do
|
81
|
+
member_with_fake_riid = Responsys::Member.new(@email, "000001")
|
82
|
+
bool = member_with_fake_riid.present_in_list?(@list)
|
83
|
+
|
84
|
+
expect(bool).to eq(false)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should return the record_not_found code message" do
|
89
|
+
VCR.use_cassette("member/present5") do
|
90
|
+
member_with_fake_riid = Responsys::Member.new(@email, "000001")
|
91
|
+
response = member_with_fake_riid.subscribed?(@list)
|
92
|
+
|
93
|
+
expect(response[:error][:code]).to eq("record_not_found")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
context "Get profile extension data" do
|
100
|
+
|
101
|
+
before(:each) do
|
102
|
+
VCR.use_cassette("member/login") do
|
103
|
+
@profile_extension = Responsys::Api::Object::InteractObject.new("demo_folder2", "customers_extension")
|
104
|
+
@riid = 1125
|
105
|
+
@member_without_riid = Responsys::Member.new(@email)
|
106
|
+
@member_with_riid = Responsys::Member.new(@email, @riid)
|
107
|
+
@fields = %w(RIID_ EMAIL_ADDRESS)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should set the status to failure if no riid provided" do
|
112
|
+
VCR.use_cassette("member/retrieve_profile_extension_fail") do
|
113
|
+
response = @member_without_riid.retrieve_profile_extension(@profile_extension, @fields)
|
114
|
+
|
115
|
+
expect(response[:status]).to eq("failure")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should set a i18n message in the response if no riid provided" do
|
120
|
+
VCR.use_cassette("member/retrieve_profile_extension_fail") do
|
121
|
+
response = @member_without_riid.retrieve_profile_extension(@profile_extension, @fields)
|
122
|
+
|
123
|
+
expect(response[:error][:message]).to eq(I18n.t("member.riid_missing"))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should set the status to ok" do
|
128
|
+
VCR.use_cassette("member/retrieve_profile_extension") do
|
129
|
+
response = @member_with_riid.retrieve_profile_extension(@profile_extension, @fields)
|
130
|
+
|
131
|
+
expect(response[:status]).to eq("ok")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/setup"
|
2
2
|
Bundler.setup
|
3
3
|
|
4
|
-
require
|
4
|
+
require "responsys_api.rb"
|
5
|
+
require "vcr"
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
9
|
+
c.hook_into :webmock
|
10
|
+
end
|
11
|
+
|
12
|
+
Responsys.configure do |config|
|
13
|
+
config.settings = {
|
14
|
+
username: "your_responsys_username",
|
15
|
+
password: "your_responsys_password",
|
16
|
+
wsdl: "https://wsxxxx.responsys.net/webservices/wsdl/ResponsysWS_Level1.wsdl",
|
17
|
+
debug: false
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Responsys.configure do |config|
|
22
|
+
# config.settings = {
|
23
|
+
# username: "your_responsys_username",
|
24
|
+
# password: "your_responsys_password",
|
25
|
+
# wsdl: "https://wsxxxx.responsys.net/webservices/wsdl/ResponsysWS_Level1.wsdl",
|
26
|
+
# debug: false
|
27
|
+
# }
|
28
|
+
# end
|
29
|
+
|
30
|
+
I18n.enforce_available_locales = false
|