checkout_ru 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,25 +8,27 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.8
11
+ - Faraday v0.8.9
12
+ Accept:
13
+ - application/json
12
14
  response:
13
15
  status:
14
16
  code: 200
15
- message:
17
+ message:
16
18
  headers:
17
- date:
18
- - Tue, 28 Jan 2014 23:31:30 GMT
19
19
  server:
20
- - Apache/2.2.22 (Ubuntu)
21
- connection:
22
- - close
23
- transfer-encoding:
24
- - chunked
20
+ - nginx/1.7.5
21
+ date:
22
+ - Mon, 06 Oct 2014 23:09:21 GMT
25
23
  content-type:
26
24
  - application/json;charset=UTF-8
25
+ transfer-encoding:
26
+ - chunked
27
+ connection:
28
+ - close
27
29
  body:
28
30
  encoding: UTF-8
29
- string: '{"ticket":"valid-ticket"}'
30
- http_version:
31
- recorded_at: Tue, 28 Jan 2014 23:33:15 GMT
31
+ string: '{"ticket":"fc316813f27b8e2a0bc388b0efcb8b22", "receiverEmailNotRequired":false}'
32
+ http_version:
33
+ recorded_at: Mon, 06 Oct 2014 23:08:03 GMT
32
34
  recorded_with: VCR 2.8.0
@@ -8,28 +8,27 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.8
11
+ - Faraday v0.8.9
12
+ Accept:
13
+ - application/json
12
14
  response:
13
15
  status:
14
16
  code: 400
15
- message:
17
+ message:
16
18
  headers:
17
- date:
18
- - Tue, 28 Jan 2014 22:47:53 GMT
19
19
  server:
20
- - Apache/2.2.22 (Ubuntu)
21
- vary:
22
- - Accept-Encoding
23
- connection:
24
- - close
25
- transfer-encoding:
26
- - chunked
20
+ - nginx/1.7.5
21
+ date:
22
+ - Mon, 06 Oct 2014 23:11:17 GMT
27
23
  content-type:
28
24
  - text/plain;charset=UTF-8
25
+ transfer-encoding:
26
+ - chunked
27
+ connection:
28
+ - close
29
29
  body:
30
- encoding: ASCII-8BIT
31
- string: !binary |-
32
- 0J3QtdCy0LXRgNC90YvQuSDQuNC00LXQvdGC0LjRhNC40LrQsNGC0L7RgA==
33
- http_version:
34
- recorded_at: Tue, 28 Jan 2014 22:49:38 GMT
30
+ encoding: UTF-8
31
+ string: "Неверный идентификатор"
32
+ http_version:
33
+ recorded_at: Mon, 06 Oct 2014 23:09:59 GMT
35
34
  recorded_with: VCR 2.8.0
@@ -2,10 +2,12 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://platform.checkout.ru/service/order/status/75
5
+ uri: http://platform.checkout.ru/service/order/create
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"apiKey":"valid-api-key","status":"CANCELLED_BEFORE_SHIPMENT"}'
8
+ string: '{"order":{"goods":[{"name":"blue tshirt","code":"blt","variantCode":"blue","quantity":2,"assessedCost":1000,"payCost":750,"weight":0.5}],"delivery":{"deliveryId":2,"placeFiasId":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5","addressPvz":"1-я
9
+ Квесисская улица, 18","type":"postamat","cost":230,"minTerm":1,"maxTerm":2},"user":{"fullname":"Test
10
+ Order","email":"testorder@example.com","phone":"555"},"comment":"TEST ORDER","shopOrderId":"12","paymentMethod":"cash"},"apiKey":"valid-api-key"}'
9
11
  headers:
10
12
  User-Agent:
11
13
  - Faraday v0.8.9
@@ -16,19 +18,52 @@ http_interactions:
16
18
  response:
17
19
  status:
18
20
  code: 200
19
- message:
21
+ message:
20
22
  headers:
21
- date:
22
- - Sat, 01 Feb 2014 19:33:54 GMT
23
23
  server:
24
- - Apache/2.2.22 (Ubuntu)
24
+ - nginx/1.7.5
25
+ date:
26
+ - Tue, 07 Oct 2014 00:55:40 GMT
27
+ content-type:
28
+ - application/json;charset=UTF-8
29
+ transfer-encoding:
30
+ - chunked
25
31
  connection:
26
32
  - close
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"order":{"id":32857},"delivery":{"id":2,"serviceName":"PickPoint","cost":"230.0"}}'
36
+ http_version:
37
+ recorded_at: Tue, 07 Oct 2014 00:54:21 GMT
38
+ - request:
39
+ method: post
40
+ uri: http://platform.checkout.ru/service/order/status/32857
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"status":"CANCELLED_BEFORE_SHIPMENT","apiKey":"valid-api-key"}'
44
+ headers:
45
+ User-Agent:
46
+ - Faraday v0.8.9
47
+ Accept:
48
+ - application/json
49
+ Content-Type:
50
+ - application/json
51
+ response:
52
+ status:
53
+ code: 200
54
+ message:
55
+ headers:
56
+ server:
57
+ - nginx/1.7.5
58
+ date:
59
+ - Tue, 07 Oct 2014 00:55:40 GMT
27
60
  transfer-encoding:
28
61
  - chunked
62
+ connection:
63
+ - close
29
64
  body:
30
65
  encoding: UTF-8
31
66
  string: ''
32
- http_version:
33
- recorded_at: Sat, 01 Feb 2014 19:35:06 GMT
67
+ http_version:
68
+ recorded_at: Tue, 07 Oct 2014 00:54:22 GMT
34
69
  recorded_with: VCR 2.8.0
@@ -1,8 +1,43 @@
1
1
  ---
2
2
  http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://platform.checkout.ru/service/order/create
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"order":{"goods":[{"name":"blue tshirt","code":"blt","variantCode":"blue","quantity":2,"assessedCost":1000,"payCost":750,"weight":0.5}],"delivery":{"deliveryId":2,"placeFiasId":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5","addressPvz":"1-я
9
+ Квесисская улица, 18","type":"postamat","cost":230,"minTerm":1,"maxTerm":2},"user":{"fullname":"Test
10
+ Order","email":"testorder@example.com","phone":"555"},"comment":"TEST ORDER","paymentMethod":"cash"},"apiKey":"valid-api-key"}'
11
+ headers:
12
+ User-Agent:
13
+ - Faraday v0.8.9
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message:
22
+ headers:
23
+ server:
24
+ - nginx/1.7.5
25
+ date:
26
+ - Tue, 07 Oct 2014 01:07:03 GMT
27
+ content-type:
28
+ - application/json;charset=UTF-8
29
+ transfer-encoding:
30
+ - chunked
31
+ connection:
32
+ - close
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"order":{"id":32873},"delivery":{"id":2,"serviceName":"PickPoint","cost":"230.0"}}'
36
+ http_version:
37
+ recorded_at: Tue, 07 Oct 2014 01:05:45 GMT
3
38
  - request:
4
39
  method: get
5
- uri: http://platform.checkout.ru/service/order/statushistory/777?apiKey=valid-api-key
40
+ uri: http://platform.checkout.ru/service/order/statushistory/32873?apiKey=valid-api-key
6
41
  body:
7
42
  encoding: US-ASCII
8
43
  string: ''
@@ -14,29 +49,25 @@ http_interactions:
14
49
  response:
15
50
  status:
16
51
  code: 200
17
- message:
52
+ message:
18
53
  headers:
19
- date:
20
- - Sat, 01 Feb 2014 19:39:16 GMT
21
54
  server:
22
- - Apache/2.2.22 (Ubuntu)
23
- connection:
24
- - close
25
- transfer-encoding:
26
- - chunked
55
+ - nginx/1.7.5
56
+ date:
57
+ - Tue, 07 Oct 2014 01:07:03 GMT
27
58
  content-type:
28
59
  - application/json;charset=UTF-8
60
+ transfer-encoding:
61
+ - chunked
62
+ connection:
63
+ - close
29
64
  body:
30
- encoding: ASCII-8BIT
31
- string: !binary |-
32
- ewoib3JkZXIiOnsKImlkIjoiNzUiLCAKImRhdGUiOiIxLjAyLjIwMTQiLCAK
33
- InRvdGFsQ29zdCI6MTcyNC40MSwgCiJhcHByb3hpbWF0ZURlbGl2ZXJ5RGF0
34
- ZSI6bnVsbH0sInVzZXIiOnsKImZ1bGxuYW1lIjoi0J/QtdGC0Y8g0J/Rg9C/
35
- 0LrQuNC9IiwgCiJhZGRyZXNzIjp7CiJwb3N0aW5kZXgiOm51bGwsIAoicGxh
36
- Y2UiOiLQsy4g0JzQvtGB0LrQstCwIiwKInN0cmVldCI6IiIsCiJob3VzZSI6
37
- bnVsbCwgCiJob3VzaW5nIjpudWxsLCAKImJ1aWxkaW5nIjpudWxsLCAKImFw
38
- cGFydG1lbnQiOm51bGx9fSwiZGVsaXZlcnlOYW1lIjoiUGlja1BvaW50Iiwg
39
- ImRlbGl2ZXJ5SGlzdG9yeSIgOiBbCgpdCn0=
40
- http_version:
41
- recorded_at: Sat, 01 Feb 2014 19:40:27 GMT
65
+ encoding: UTF-8
66
+ string: "{\n\"order\":{\n\"id\":\"32873\", \n\"date\":\"7.10.2014\", \n\"totalCost\":1730.0,
67
+ \n\"approximateDeliveryDate\":null},\"user\":{\n\"fullname\":\"Test Order\",
68
+ \n\"address\":{\n\"postindex\":null, \n\"place\":\"г. Москва\",\n\"street\":\"\",\n\"house\":null,
69
+ \n\"housing\":null, \n\"building\":null, \n\"appartment\":null}},\"deliveryName\":\"PickPoint\",
70
+ \"deliveryHistory\" : [\n\n]\n}"
71
+ http_version:
72
+ recorded_at: Tue, 07 Oct 2014 01:05:45 GMT
42
73
  recorded_with: VCR 2.8.0
@@ -2,13 +2,12 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://platform.checkout.ru/service/order/75
5
+ uri: http://platform.checkout.ru/service/order/create
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"apiKey":"valid-api-key","order":{"goods":[{"name":"blue
9
- tshirt","code":"blt","variantCode":"blue","quantity":2,"assessedCost":1000,"payCost":750,"weight":0.5}],"delivery":{"deliveryId":2,"placeFiasId":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5","addressPvz":"Энтузиастов
10
- ш., д. 54","type":"postamat","cost":224.41,"minTerm":2,"maxTerm":11},"user":{"fullname":"Петя
11
- Пупкин","email":"vasyapupkin@example.com","phone":"555"},"comment":"test order","shopOrderId":"777","paymentMethod":"cash"}}'
8
+ string: '{"order":{"goods":[{"name":"blue tshirt","code":"blt","variantCode":"blue","quantity":2,"assessedCost":1000,"payCost":750,"weight":0.5}],"delivery":{"deliveryId":2,"placeFiasId":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5","addressPvz":"1-я
9
+ Квесисская улица, 18","type":"postamat","cost":230,"minTerm":1,"maxTerm":2},"user":{"fullname":"Вася
10
+ Пупкин","email":"vasyapupkin@example.com","phone":"555"},"comment":"test order","shopOrderId":"11","paymentMethod":"cash"},"apiKey":"valid-api-key"}'
12
11
  headers:
13
12
  User-Agent:
14
13
  - Faraday v0.8.9
@@ -19,21 +18,56 @@ http_interactions:
19
18
  response:
20
19
  status:
21
20
  code: 200
22
- message:
21
+ message:
23
22
  headers:
24
- date:
25
- - Sat, 01 Feb 2014 19:27:28 GMT
26
23
  server:
27
- - Apache/2.2.22 (Ubuntu)
28
- connection:
29
- - close
24
+ - nginx/1.7.5
25
+ date:
26
+ - Tue, 07 Oct 2014 00:53:10 GMT
27
+ content-type:
28
+ - application/json;charset=UTF-8
30
29
  transfer-encoding:
31
30
  - chunked
31
+ connection:
32
+ - close
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"order":{"id":32855},"delivery":{"id":2,"serviceName":"PickPoint","cost":"230.0"}}'
36
+ http_version:
37
+ recorded_at: Tue, 07 Oct 2014 00:51:52 GMT
38
+ - request:
39
+ method: post
40
+ uri: http://platform.checkout.ru/service/order/32855
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"order":{"goods":[{"name":"blue tshirt","code":"blt","variantCode":"blue","quantity":2,"assessedCost":1000,"payCost":750,"weight":0.5}],"delivery":{"deliveryId":2,"placeFiasId":"0c5b2444-70a0-4932-980c-b4dc0d3f02b5","addressPvz":"1-я
44
+ Квесисская улица, 18","type":"postamat","cost":230,"minTerm":1,"maxTerm":2},"user":{"fullname":"Петя
45
+ Пупкин","email":"vasyapupkin@example.com","phone":"555"},"comment":"test order","shopOrderId":"11","paymentMethod":"cash"},"apiKey":"valid-api-key"}'
46
+ headers:
47
+ User-Agent:
48
+ - Faraday v0.8.9
49
+ Accept:
50
+ - application/json
51
+ Content-Type:
52
+ - application/json
53
+ response:
54
+ status:
55
+ code: 200
56
+ message:
57
+ headers:
58
+ server:
59
+ - nginx/1.7.5
60
+ date:
61
+ - Tue, 07 Oct 2014 00:53:11 GMT
32
62
  content-type:
33
63
  - application/json;charset=UTF-8
64
+ transfer-encoding:
65
+ - chunked
66
+ connection:
67
+ - close
34
68
  body:
35
69
  encoding: UTF-8
36
- string: '{"order":{"id":75},"delivery":{"id":2,"serviceName":"PickPoint"}}'
37
- http_version:
38
- recorded_at: Sat, 01 Feb 2014 19:28:41 GMT
70
+ string: '{"order":{"id":32855},"delivery":{"id":2,"serviceName":"PickPoint","cost":"230.0"}}'
71
+ http_version:
72
+ recorded_at: Tue, 07 Oct 2014 00:51:52 GMT
39
73
  recorded_with: VCR 2.8.0
data/test/test_helper.rb CHANGED
@@ -2,8 +2,39 @@ require 'checkout_ru'
2
2
  require 'minitest/autorun'
3
3
  require 'mocha/mini_test'
4
4
  require 'vcr'
5
+ require 'cgi'
6
+
7
+ REAL_API_KEY = ENV['CHECKOUT_RU_API_KEY']
8
+ CheckoutRu.api_key = ENV['CHECKOUT_RU_API_KEY'] || 'valid-api-key'
9
+ CheckoutRu.auto_renew_session = true
5
10
 
6
11
  VCR.configure do |c|
7
12
  c.cassette_library_dir = 'test/fixtures'
8
13
  c.hook_into :faraday
14
+
15
+ if REAL_API_KEY
16
+ c.filter_sensitive_data('valid-api-key') { CheckoutRu.api_key }
17
+ end
18
+
19
+ c.before_record do |i|
20
+ i.response.body.force_encoding('UTF-8')
21
+ end
22
+
23
+ # From here: https://github.com/vcr/vcr/wiki/Common-Custom-Matchers
24
+ c.register_request_matcher :uri_ignoring_params_order do |r1, r2|
25
+ uri1 = URI(r1.uri)
26
+ uri2 = URI(r2.uri)
27
+
28
+ uri1.scheme == uri2.scheme &&
29
+ uri1.host == uri2.host &&
30
+ uri1.path == uri2.path &&
31
+ CGI.parse(uri1.query || '') == CGI.parse(uri2.query || '')
32
+ end
33
+
34
+ cassette_options = {
35
+ :match_requests_on => [:method, :uri_ignoring_params_order],
36
+ :decode_compressed_response => true
37
+ }
38
+ cassette_options.merge!(:re_record_interval => 0) if REAL_API_KEY
39
+ c.default_cassette_options = cassette_options
9
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkout_ru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday