buyatabwrapper 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6d54ed29b78ba6e06ead5327f42b4b1818bad7b
4
- data.tar.gz: 98d819452b64442fc753bda8472111b1e26e14d5
3
+ metadata.gz: 656db0676ef83cc5b32893636c8b27dbf2d8787a
4
+ data.tar.gz: 60554113f071df525cd07e449fed36ecedde1c4e
5
5
  SHA512:
6
- metadata.gz: ebf46892e638755ce5684b2c042654abad16a1a4f3b3bcaf8c73b0d2583819756897a2b9ea4d9217b73cc3e99cf273c3d73bac3f416fb1d93a57090e55570bc7
7
- data.tar.gz: e94570defcff710ae6124873a3bb380b59c9f33f8e583b6db18f1effcf360ac778533596d073fc299a29a307f2d484928a9a52e9c2576117294a4705f89a78fc
6
+ metadata.gz: cf07b16c9bf5bed4b7200cfe66c74de5e0f2218e7e85a2804e223664d546d91ab0beeea5632ddceac2ddb09ca9b2bf4a7acc2d76f3defad14ea90fb106849bc0
7
+ data.tar.gz: 120bd1b8bb6b1c8d45e7d157b4090a15111903f7264386235418ed59b894bf0ce0d4bbb0e9a480a4df65592e789360eebaa48bc4e6e1aba52c6be426f94b095c
@@ -13,14 +13,10 @@ module Buyatabwrapper
13
13
  CALLS = {
14
14
  get_merchants: {
15
15
  url: '/gcp/services/BuyatabWS.asmx/GetMerchantList',
16
- field_to_return: 'Merchants',
17
- action_type: :get,
18
16
  default_params: {}
19
17
  },
20
18
  purchase_card: {
21
19
  url: '/gcp/services/BuyatabWS.asmx/PurchaseCard',
22
- field_to_return: 'BATOrderNumber',
23
- action_type: :post,
24
20
  default_params: {
25
21
  cardstyle_id: '0',
26
22
  msg: '',
@@ -57,10 +53,15 @@ module Buyatabwrapper
57
53
  response = JSON.parse(response.body)["d"]
58
54
 
59
55
  if response["Status"]["Success"]
60
- if CALLS[type][:action_type] == :get
61
- self.result = response[CALLS[type][:field_to_return]]
56
+ if type == :get_merchants
57
+ self.result = response['Merchants']
62
58
  else
63
- result.response = response[CALLS[type][:field_to_return]]
59
+ result.response = OpenStruct.new(
60
+ id: response['BATOrderNumber'],
61
+ url: response['Links'].first,
62
+ card_number: response['CardNumbers'].first,
63
+ pin_number: response['CardPins'].first
64
+ )
64
65
  result.successful!
65
66
  end
66
67
  else
@@ -90,3 +91,4 @@ module Buyatabwrapper
90
91
  end
91
92
  end
92
93
  end
94
+
@@ -1,3 +1,3 @@
1
1
  module Buyatabwrapper
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -35,14 +35,14 @@ http_interactions:
35
35
  Access-Control-Allow-Methods:
36
36
  - GET, POST, OPTIONS
37
37
  Date:
38
- - Tue, 07 Apr 2015 12:35:20 GMT
38
+ - Mon, 22 Jun 2015 11:18:27 GMT
39
39
  Content-Length:
40
- - '562'
40
+ - '561'
41
41
  body:
42
42
  encoding: UTF-8
43
43
  string: '{"d":{"__type":"PurchaseResponse","Status":{"__type":"gcp.objects.Status","Error":{"ErrorCode":0,"Message":"SUCCESS","ExceptionDetails":"Test
44
- Mode Success."},"Success":true},"ServerTime":"07 April 2015 05:35:20","AdditionalNotes":"|
44
+ Mode Success."},"Success":true},"ServerTime":"22 June 2015 04:18:27","AdditionalNotes":"|
45
45
  Test Mode Enabled.\r\n","RemainingBalance":12345.00,"BATOrderNumber":12345,"CustomerReferenceId":"","CustomerReferenceId2":"","OptIn":false,"Links":["https://www.buyatab.com/gcp/ecard.aspx?Id=JjD4DcN3vDv7IINuKFrweg%3d%3d"],"CardNumbers":["1234567890123456"],"CardPins":["1234"],"ExternalURLs":["someurl.com"],"Secrets":["shhh"]}}'
46
46
  http_version:
47
- recorded_at: Tue, 07 Apr 2015 12:36:46 GMT
47
+ recorded_at: Mon, 22 Jun 2015 11:20:45 GMT
48
48
  recorded_with: VCR 2.9.3
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.buyatab.com/gcp/services/BuyatabWS.asmx/PurchaseCard
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"username":"who2tryapi","password":"P8dFwyR22ed7dDjxxL","apitoken":"e2ZE7/H6mASptB3pfTjGgj/nYXQxGn8b3ltiLEkQc4M=","cardstyle_id":"0","msg":"","quantity":"1","recipient_name":"","recipient_email":"","sender_name":"","sender_email":"","handle_delivery":"true","customer_ref_id":"","opt_in":"true","merchant_id":"22","amount":"10.00"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - private, max-age=0
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Server:
28
+ - Microsoft-IIS/8.5
29
+ X-Aspnet-Version:
30
+ - 4.0.30319
31
+ Access-Control-Allow-Origin:
32
+ - https://portal.buyatab.com
33
+ Access-Control-Allow-Headers:
34
+ - Content-Type
35
+ Access-Control-Allow-Methods:
36
+ - GET, POST, OPTIONS
37
+ Date:
38
+ - Mon, 22 Jun 2015 11:22:55 GMT
39
+ Content-Length:
40
+ - '561'
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"d":{"__type":"PurchaseResponse","Status":{"__type":"gcp.objects.Status","Error":{"ErrorCode":0,"Message":"SUCCESS","ExceptionDetails":"Test
44
+ Mode Success."},"Success":true},"ServerTime":"22 June 2015 04:22:56","AdditionalNotes":"|
45
+ Test Mode Enabled.\r\n","RemainingBalance":12345.00,"BATOrderNumber":12345,"CustomerReferenceId":"","CustomerReferenceId2":"","OptIn":false,"Links":["https://www.buyatab.com/gcp/ecard.aspx?Id=JjD4DcN3vDv7IINuKFrweg%3d%3d"],"CardNumbers":["1234567890123456"],"CardPins":["1234"],"ExternalURLs":["someurl.com"],"Secrets":["shhh"]}}'
46
+ http_version:
47
+ recorded_at: Mon, 22 Jun 2015 11:25:14 GMT
48
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.buyatab.com/gcp/services/BuyatabWS.asmx/PurchaseCard
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"username":"who2tryapi","password":"P8dFwyR22ed7dDjxxL","apitoken":"e2ZE7/H6mASptB3pfTjGgj/nYXQxGn8b3ltiLEkQc4M=","cardstyle_id":"0","msg":"","quantity":"1","recipient_name":"","recipient_email":"","sender_name":"","sender_email":"","handle_delivery":"true","customer_ref_id":"","opt_in":"true","merchant_id":"22","amount":"10.00"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - private, max-age=0
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Server:
28
+ - Microsoft-IIS/8.5
29
+ X-Aspnet-Version:
30
+ - 4.0.30319
31
+ Access-Control-Allow-Origin:
32
+ - https://portal.buyatab.com
33
+ Access-Control-Allow-Headers:
34
+ - Content-Type
35
+ Access-Control-Allow-Methods:
36
+ - GET, POST, OPTIONS
37
+ Date:
38
+ - Mon, 22 Jun 2015 11:18:27 GMT
39
+ Content-Length:
40
+ - '561'
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"d":{"__type":"PurchaseResponse","Status":{"__type":"gcp.objects.Status","Error":{"ErrorCode":0,"Message":"SUCCESS","ExceptionDetails":"Test
44
+ Mode Success."},"Success":true},"ServerTime":"22 June 2015 04:18:28","AdditionalNotes":"|
45
+ Test Mode Enabled.\r\n","RemainingBalance":12345.00,"BATOrderNumber":12345,"CustomerReferenceId":"","CustomerReferenceId2":"","OptIn":false,"Links":["https://www.buyatab.com/gcp/ecard.aspx?Id=JjD4DcN3vDv7IINuKFrweg%3d%3d"],"CardNumbers":["1234567890123456"],"CardPins":["1234"],"ExternalURLs":["someurl.com"],"Secrets":["shhh"]}}'
46
+ http_version:
47
+ recorded_at: Mon, 22 Jun 2015 11:20:46 GMT
48
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.buyatab.com/gcp/services/BuyatabWS.asmx/PurchaseCard
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"username":"who2tryapi","password":"P8dFwyR22ed7dDjxxL","apitoken":"e2ZE7/H6mASptB3pfTjGgj/nYXQxGn8b3ltiLEkQc4M=","cardstyle_id":"0","msg":"","quantity":"1","recipient_name":"","recipient_email":"","sender_name":"","sender_email":"","handle_delivery":"true","customer_ref_id":"","opt_in":"true","merchant_id":"22","amount":"10.00"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Cache-Control:
24
+ - private, max-age=0
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Server:
28
+ - Microsoft-IIS/8.5
29
+ X-Aspnet-Version:
30
+ - 4.0.30319
31
+ Access-Control-Allow-Origin:
32
+ - https://portal.buyatab.com
33
+ Access-Control-Allow-Headers:
34
+ - Content-Type
35
+ Access-Control-Allow-Methods:
36
+ - GET, POST, OPTIONS
37
+ Date:
38
+ - Mon, 22 Jun 2015 11:22:55 GMT
39
+ Content-Length:
40
+ - '561'
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"d":{"__type":"PurchaseResponse","Status":{"__type":"gcp.objects.Status","Error":{"ErrorCode":0,"Message":"SUCCESS","ExceptionDetails":"Test
44
+ Mode Success."},"Success":true},"ServerTime":"22 June 2015 04:22:55","AdditionalNotes":"|
45
+ Test Mode Enabled.\r\n","RemainingBalance":12345.00,"BATOrderNumber":12345,"CustomerReferenceId":"","CustomerReferenceId2":"","OptIn":false,"Links":["https://www.buyatab.com/gcp/ecard.aspx?Id=JjD4DcN3vDv7IINuKFrweg%3d%3d"],"CardNumbers":["1234567890123456"],"CardPins":["1234"],"ExternalURLs":["someurl.com"],"Secrets":["shhh"]}}'
46
+ http_version:
47
+ recorded_at: Mon, 22 Jun 2015 11:25:13 GMT
48
+ recorded_with: VCR 2.9.3
@@ -22,8 +22,20 @@ describe Buyatabwrapper::API do
22
22
  expect(subject.send_request(:purchase_card, params).successful?).to be_truthy
23
23
  end
24
24
 
25
- it 'returns response' do
26
- expect(subject.send_request(:purchase_card, params).response).to eq(12345)
25
+ it 'returns transaction id' do
26
+ expect(subject.send_request(:purchase_card, params).response.id).to eq(12345)
27
+ end
28
+
29
+ it 'returns link to card' do
30
+ expect(subject.send_request(:purchase_card, params).response.url).to eq('https://www.buyatab.com/gcp/ecard.aspx?Id=JjD4DcN3vDv7IINuKFrweg%3d%3d')
31
+ end
32
+
33
+ it 'returns card number' do
34
+ expect(subject.send_request(:purchase_card, params).response.card_number).to eq('1234567890123456')
35
+ end
36
+
37
+ it 'returns pin number' do
38
+ expect(subject.send_request(:purchase_card, params).response.pin_number).to eq('1234')
27
39
  end
28
40
  end
29
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buyatabwrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Milevskiy
@@ -127,8 +127,11 @@ files:
127
127
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_get_merchants_call/returns_list_of_merchants.yml
128
128
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_invalid_params/returns_error.yml
129
129
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_invalid_params/returns_unsuccessful_result.yml
130
- - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_response.yml
130
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_card_number.yml
131
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_link_to_card.yml
132
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_pin_number.yml
131
133
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_successful_result.yml
134
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_transaction_id.yml
132
135
  - spec/config/buyatabwrapper.yml
133
136
  - spec/lib/buyatabwrapper/api_spec.rb
134
137
  - spec/lib/buyatabwrapper_spec.rb
@@ -162,8 +165,11 @@ test_files:
162
165
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_get_merchants_call/returns_list_of_merchants.yml
163
166
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_invalid_params/returns_error.yml
164
167
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_invalid_params/returns_unsuccessful_result.yml
165
- - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_response.yml
168
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_card_number.yml
169
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_link_to_card.yml
170
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_pin_number.yml
166
171
  - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_successful_result.yml
172
+ - spec/cassettes/Buyatabwrapper_API/_send_request/with_configs/for_purchase_card_call/returns_transaction_id.yml
167
173
  - spec/config/buyatabwrapper.yml
168
174
  - spec/lib/buyatabwrapper/api_spec.rb
169
175
  - spec/lib/buyatabwrapper_spec.rb