forte_ruby 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/forte_ruby.gemspec +30 -0
- data/lib/forte_ruby/api/base.rb +52 -0
- data/lib/forte_ruby/api/object.rb +52 -0
- data/lib/forte_ruby/api/objects.rb +51 -0
- data/lib/forte_ruby/api/request_data.rb +45 -0
- data/lib/forte_ruby/resourses/address.rb +27 -0
- data/lib/forte_ruby/resourses/addresses.rb +22 -0
- data/lib/forte_ruby/resourses/customer.rb +29 -0
- data/lib/forte_ruby/resourses/customers.rb +16 -0
- data/lib/forte_ruby/resourses/settlement.rb +43 -0
- data/lib/forte_ruby/resourses/settlements.rb +16 -0
- data/lib/forte_ruby/resourses/transaction.rb +34 -0
- data/lib/forte_ruby/resourses/transactions.rb +16 -0
- data/lib/forte_ruby/version.rb +3 -0
- data/lib/forte_ruby.rb +27 -0
- data/spec/cassettes/address/create/error.yml +59 -0
- data/spec/cassettes/address/create/success.yml +52 -0
- data/spec/cassettes/address/delete/success.yml +50 -0
- data/spec/cassettes/addresses/empty.yml +50 -0
- data/spec/cassettes/addresses/many.yml +51 -0
- data/spec/cassettes/customer/create/error.yml +56 -0
- data/spec/cassettes/customer/create/success.yml +52 -0
- data/spec/cassettes/customer/delete/success.yml +50 -0
- data/spec/cassettes/customer/update/error.yml +59 -0
- data/spec/cassettes/customer/update/success.yml +52 -0
- data/spec/cassettes/customers/all/empty.yml +50 -0
- data/spec/cassettes/customers/all/many.yml +51 -0
- data/spec/cassettes/customers/filter/do_not_exist.yml +50 -0
- data/spec/cassettes/customers/filter/exist.yml +51 -0
- data/spec/cassettes/customers/find_by_id/does_not_exist.yml +53 -0
- data/spec/cassettes/customers/find_by_id/exists.yml +50 -0
- data/spec/cassettes/settlements/empty.yml +50 -0
- data/spec/cassettes/settlements/many.yml +50 -0
- data/spec/cassettes/transactions/empty.yml +50 -0
- data/spec/cassettes/transactions/many.yml +51 -0
- data/spec/config/forte_ruby.yml +6 -0
- data/spec/forte_ruby/api/base_spec.rb +24 -0
- data/spec/forte_ruby/api/object_spec.rb +90 -0
- data/spec/forte_ruby/api/objects_spec.rb +88 -0
- data/spec/forte_ruby/api/request_data_spec.rb +33 -0
- data/spec/forte_ruby/resourses/address_spec.rb +100 -0
- data/spec/forte_ruby/resourses/addresses_spec.rb +30 -0
- data/spec/forte_ruby/resourses/customer_spec.rb +90 -0
- data/spec/forte_ruby/resourses/customers_spec.rb +53 -0
- data/spec/forte_ruby/resourses/settlements_spec.rb +25 -0
- data/spec/forte_ruby/resourses/transactions_spec.rb +25 -0
- data/spec/spec_helper.rb +19 -0
- data/tasks/rspec.rake +3 -0
- metadata +241 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/customers?filter=first_name%20eq%20Mike
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Wed, 18 Mar 2015 13:27:58 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=0DBF2E22300A61A18D35B33164C4A32E;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '1702'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"number_results":2,"results":[{"links":{"settlements":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/settlements","transactions":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/transactions","paymethods":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/paymethods","addresses":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/addresses","self":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ"},"status":"active","company_name":"","last_name":"Mil","first_name":"Mike","customer_id":"","location_id":"loc_169531","account_id":"act_300044","customer_token":"cst_5I5j8RuSCU6kmt3_miCtZQ"},{"links":{"settlements":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_XDeMYtR1xE2e5mBVOx0q9w/settlements","transactions":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_XDeMYtR1xE2e5mBVOx0q9w/transactions","paymethods":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_XDeMYtR1xE2e5mBVOx0q9w/paymethods","addresses":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_XDeMYtR1xE2e5mBVOx0q9w/addresses","self":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_XDeMYtR1xE2e5mBVOx0q9w"},"status":"active","company_name":"","last_name":"","first_name":"Mike","customer_id":"","location_id":"loc_169531","account_id":"act_300044","customer_token":"cst_XDeMYtR1xE2e5mBVOx0q9w"}],"response":{"response_desc":"Get
|
48
|
+
Successful.","environment":"sandbox"},"links":{"self":"/API/v1/accounts/act_300044/locations/loc_169531/customers?filter=first_name+eq+Mike"}}'
|
49
|
+
http_version:
|
50
|
+
recorded_at: Wed, 18 Mar 2015 13:27:59 GMT
|
51
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZd
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 401
|
23
|
+
message: Unauthorized
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
Www-Authenticate:
|
28
|
+
- Basic realm="sandbox.forte.net"
|
29
|
+
X-Aspnet-Version:
|
30
|
+
- 4.0.30319
|
31
|
+
Cache-Control:
|
32
|
+
- no-cache
|
33
|
+
Content-Type:
|
34
|
+
- application/json; charset=utf-8
|
35
|
+
Date:
|
36
|
+
- Wed, 18 Mar 2015 13:24:58 GMT
|
37
|
+
Expires:
|
38
|
+
- "-1"
|
39
|
+
Pragma:
|
40
|
+
- no-cache
|
41
|
+
Set-Cookie:
|
42
|
+
- X-Mapping-gbooldlg=DFC7CDDF5472E60DACDF1BDF84C0518B;path=/
|
43
|
+
X-Powered-By:
|
44
|
+
- ASP.NET
|
45
|
+
Content-Length:
|
46
|
+
- '142'
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"response":{"response_desc":"This user does not have permission to
|
50
|
+
access one or more of the requested Ids/Tokens.","environment":"sandbox"}}'
|
51
|
+
http_version:
|
52
|
+
recorded_at: Wed, 18 Mar 2015 13:24:59 GMT
|
53
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Wed, 18 Mar 2015 13:23:04 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=0DBF2E22300A61A18D35B33164C4A32E;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '819'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"response":{"response_desc":"Get Successful.","environment":"sandbox"},"links":{"settlements":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/settlements","transactions":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/transactions","paymethods":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/paymethods","addresses":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/addresses","self":"/API/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ"},"status":"active","company_name":"","last_name":"Mil","first_name":"Mike","customer_id":"","location_id":"loc_169531","account_id":"act_300044","customer_token":"cst_5I5j8RuSCU6kmt3_miCtZQ"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Wed, 18 Mar 2015 13:23:04 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/settlements
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Tue, 17 Mar 2015 16:21:25 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=DFC7CDDF5472E60DACDF1BDF84C0518B;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '866'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"number_results":0,"results":[],"response":{"response_desc":"Get Successful.","environment":"sandbox"},"links":{"self":"/API/v1/accounts/act_300044/locations/loc_169531/settlements"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Tue, 17 Mar 2015 16:21:27 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/settlements
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Tue, 17 Mar 2015 16:21:25 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=DFC7CDDF5472E60DACDF1BDF84C0518B;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '866'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"number_results": "2", "results": [{"method": "cc", "links": {"self": "/v1/accounts/act_200000/locations/loc_100000/settlements/stl_51cf4633-1767-484f-8784-be76a4076791"}, "settle_amount": 0, "settle_type": "reject", "settle_date": "2014-07-31T12: 35: 52", "settle_response_code": "R20", "reference_id": "000003", "order_number": "000002", "customer_id": "000001", "transaction_id": "trn_7109c960-bb36-425b-a0f6-94a6285e177f", "location_id": "loc_100000", "account_id": "act_300005", "settle_id": "stl_51cf4633-1767-484f-8784-be76a4076791"}], "response": {"response_desc": "Get Successful.", "environment": "live"}, "links": {"self": "/v1/accounts/act_200000/locations/loc_100000/settlements"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Tue, 17 Mar 2015 16:21:27 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/transactions
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Tue, 17 Mar 2015 16:21:25 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=DFC7CDDF5472E60DACDF1BDF84C0518B;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '866'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"number_results":0,"results":[],"response":{"response_desc":"Get Successful.","environment":"sandbox"},"links":{"self":"/API/v1/accounts/act_300044/locations/loc_169531/transactions"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Tue, 17 Mar 2015 16:21:27 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/transactions
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
Date:
|
34
|
+
- Tue, 17 Mar 2015 16:21:25 GMT
|
35
|
+
Expires:
|
36
|
+
- "-1"
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- X-Mapping-gbooldlg=DFC7CDDF5472E60DACDF1BDF84C0518B;path=/
|
41
|
+
X-Powered-By:
|
42
|
+
- ASP.NET
|
43
|
+
Content-Length:
|
44
|
+
- '866'
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"number_results":1,"results":[{"response":{"response_code":"A01"},"links":{"settlements":"/API/v1/accounts/act_300044/locations/loc_169531/transactions/trn_486d8c54-e1cf-402f-bebb-7cac710ab650/settlements","self":"/API/v1/accounts/act_300044/locations/loc_169531/transactions/trn_486d8c54-e1cf-402f-bebb-7cac710ab650"},"transaction_id":"trn_486d8c54-e1cf-402f-bebb-7cac710ab650","account_id":"act_300044","location_id":"loc_169531","customer_id":"","order_number":"","reference_id":"","status":"ready","action":"sale","authorization_amount":1,"authorization_code":"123456","entered_by":"","received_date":"2015-03-17T16:14:52.893Z","bill_to_company_name":"","bill_to_last_name":"Mil","bill_to_first_name":"Rus"}],"response":{"response_desc":"Get
|
48
|
+
Successful.","environment":"sandbox"},"links":{"self":"/API/v1/accounts/act_300044/locations/loc_169531/transactions"}}'
|
49
|
+
http_version:
|
50
|
+
recorded_at: Tue, 17 Mar 2015 16:21:27 GMT
|
51
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ForteRuby::API::Base do
|
4
|
+
describe '#initialize' do
|
5
|
+
let(:request_data) { double('request_data') }
|
6
|
+
|
7
|
+
context 'request data' do
|
8
|
+
before { allow(ForteRuby::API::RequestData).to receive(:new).and_return(request_data) }
|
9
|
+
subject { ForteRuby::API::Base.new }
|
10
|
+
|
11
|
+
it 'sets request data' do
|
12
|
+
expect(subject.request_data).to eq(request_data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'attributes' do
|
17
|
+
subject { ForteRuby::API::Base.new(request_data: request_data) }
|
18
|
+
|
19
|
+
it 'sets attributes' do
|
20
|
+
expect(subject.request_data).to eq(request_data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ForteRuby::API::Object do
|
4
|
+
subject { ForteRuby::API::Object.new }
|
5
|
+
let(:attributes) {{ first_name: 'Bob' }}
|
6
|
+
|
7
|
+
describe '#delete' do
|
8
|
+
before { allow(subject).to receive(:url).and_return('delete_url') }
|
9
|
+
|
10
|
+
it 'sends delete request' do
|
11
|
+
expect(subject).to receive(:send_request).with('delete_url', :delete)
|
12
|
+
subject.delete
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns response' do
|
16
|
+
allow(subject).to receive(:send_request).and_return('success')
|
17
|
+
expect(subject.delete).to eq('success')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#update' do
|
22
|
+
before do
|
23
|
+
allow(subject).to receive(:set_attributes)
|
24
|
+
allow(subject).to receive(:save)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sets attributes before save' do
|
28
|
+
expect(subject).to receive(:set_attributes).with(attributes)
|
29
|
+
subject.update(attributes)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'calls save' do
|
33
|
+
expect(subject).to receive(:save)
|
34
|
+
subject.update(attributes)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns response' do
|
38
|
+
allow(subject).to receive(:save).and_return('success')
|
39
|
+
expect(subject.update(attributes)).to eq('success')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#save' do
|
44
|
+
let(:result) { Resultable::Result.new }
|
45
|
+
|
46
|
+
before do
|
47
|
+
allow(subject).to receive(:url).and_return('save_url')
|
48
|
+
allow(subject).to receive(:send_request).and_return(result)
|
49
|
+
allow(subject).to receive(:api_attributes_hash).and_return(attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'for persisted object' do
|
53
|
+
it 'sends put request' do
|
54
|
+
expect(subject).to receive(:send_request).with('save_url', :put, attributes).and_return(result)
|
55
|
+
subject.save
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns result' do
|
59
|
+
allow(subject).to receive(:send_request).and_return(result)
|
60
|
+
expect(subject.save).to eq(result)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'for new object' do
|
65
|
+
before { subject.new = true }
|
66
|
+
|
67
|
+
it 'sends post request' do
|
68
|
+
expect(subject).to receive(:send_request).with('save_url', :post, attributes).and_return(result)
|
69
|
+
subject.save
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns result' do
|
73
|
+
allow(subject).to receive(:send_request).and_return(result)
|
74
|
+
expect(subject.save).to eq(result)
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'if response is successful' do
|
78
|
+
before do
|
79
|
+
result.successful!
|
80
|
+
result.response = attributes
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'sets attributes from resposne' do
|
84
|
+
expect(subject).to receive(:set_attributes).with(attributes.merge(new: false))
|
85
|
+
subject.save
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ForteRuby::API::Objects do
|
4
|
+
subject { ForteRuby::API::Objects.new }
|
5
|
+
let(:request_data) { double('request_data') }
|
6
|
+
let(:single_class) { double('single_class') }
|
7
|
+
let(:new_object) { double('new_object') }
|
8
|
+
|
9
|
+
before do
|
10
|
+
allow(subject).to receive(:single_class).and_return(single_class)
|
11
|
+
allow(subject).to receive(:request_data).and_return(request_data)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#build_from' do
|
15
|
+
before { allow(single_class).to receive(:new).and_return(new_object) }
|
16
|
+
|
17
|
+
it 'initializes object of single class' do
|
18
|
+
expect(subject.build_from({})).to eq(new_object)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'sends attributes to new object' do
|
22
|
+
expect(single_class).to receive(:new).with(name: 'rus', request_data: request_data, new: true)
|
23
|
+
subject.build_from({name: 'rus'})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#all' do
|
28
|
+
let(:response) { JSON.generate(results: [{ name: 'Bob' }]) }
|
29
|
+
|
30
|
+
it 'sends request and parse response' do
|
31
|
+
expect(subject)
|
32
|
+
.to receive(:send_request)
|
33
|
+
.with('http://asd.com/customers', :get)
|
34
|
+
.and_yield(response)
|
35
|
+
.and_return([new_object])
|
36
|
+
expect(subject).to receive(:url).and_return('http://asd.com/customers')
|
37
|
+
expect(subject).to receive(:parse_response).with(response)
|
38
|
+
|
39
|
+
expect(subject.all).to eq([new_object])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#find_by_id' do
|
44
|
+
let(:response) { JSON.generate(results: [{ name: 'Bob' }]) }
|
45
|
+
|
46
|
+
it 'sends request and parse response' do
|
47
|
+
expect(subject)
|
48
|
+
.to receive(:send_request)
|
49
|
+
.with('http://asd.com/customers/123', :get)
|
50
|
+
.and_yield(response)
|
51
|
+
.and_return([new_object])
|
52
|
+
expect(subject).to receive(:url).and_return('http://asd.com/customers')
|
53
|
+
expect(subject).to receive(:parse_response).with(response)
|
54
|
+
|
55
|
+
expect(subject.find_by_id(123)).to eq([new_object])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#filter' do
|
60
|
+
let(:response) { JSON.generate(results: [{ name: 'Bob' }]) }
|
61
|
+
|
62
|
+
it 'sends request and parse response' do
|
63
|
+
expect(subject)
|
64
|
+
.to receive(:send_request)
|
65
|
+
.with('http://asd.com/customers?filter=first_name+eq+Bob+and+last_name+eq+Ronald', :get)
|
66
|
+
.and_yield(response)
|
67
|
+
.and_return([new_object])
|
68
|
+
expect(subject).to receive(:url).and_return('http://asd.com/customers')
|
69
|
+
expect(subject).to receive(:parse_response).with(response)
|
70
|
+
|
71
|
+
expect(subject.filter(first_name: 'Bob', last_name: 'Ronald')).to eq([new_object])
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'if one filter passed' do
|
75
|
+
it 'sends request with one filter' do
|
76
|
+
expect(subject)
|
77
|
+
.to receive(:send_request)
|
78
|
+
.with('http://asd.com/customers?filter=first_name+eq+Bob', :get)
|
79
|
+
.and_yield(response)
|
80
|
+
.and_return([new_object])
|
81
|
+
expect(subject).to receive(:url).and_return('http://asd.com/customers')
|
82
|
+
expect(subject).to receive(:parse_response).with(response)
|
83
|
+
|
84
|
+
expect(subject.filter(first_name: 'Bob')).to eq([new_object])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ForteRuby::API::RequestData do
|
4
|
+
subject { ForteRuby::API::RequestData.new }
|
5
|
+
|
6
|
+
it 'initializes config variable' do
|
7
|
+
expect(subject.config.account_id).to eq(300044)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#base_url' do
|
11
|
+
it 'returns base url to api' do
|
12
|
+
expect(subject.base_url).to eq('https://sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#headers' do
|
17
|
+
it 'returns hash that include account id header' do
|
18
|
+
expect(subject.headers['X-Forte-Auth-Account-Id']).to eq(subject.send('account_id'))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns hash that include authorization header' do
|
22
|
+
expect(subject.headers['Authorization']).to eq("Basic #{subject.send('signature')}")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns hash that include accept header' do
|
26
|
+
expect(subject.headers['Accept']).to eq("application/json")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns hash that include content type header' do
|
30
|
+
expect(subject.headers['Content-Type']).to eq("json")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|