spree-api-client 0.0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +674 -0
  4. data/README.md +31 -38
  5. data/lib/spree_client.rb +3 -0
  6. data/lib/spree_client.rb~ +71 -0
  7. data/lib/spree_client/api.rb +1 -0
  8. data/lib/spree_client/api/v1.rb +52 -0
  9. data/lib/spree_client/api/v1/products.rb +23 -0
  10. data/lib/spree_client/api/v1/properties.rb +12 -0
  11. data/lib/spree_client/api/v1/resources.rb +142 -0
  12. data/lib/spree_client/api/v1/stock_items.rb +27 -0
  13. data/lib/spree_client/api/v1/stock_locations.rb +33 -0
  14. data/lib/spree_client/api/v1/stock_movements.rb +16 -0
  15. data/lib/spree_client/api/v1/taxonomies.rb +12 -0
  16. data/lib/spree_client/api/v1/variants.rb +13 -0
  17. data/lib/spree_client/attributes.rb +26 -0
  18. data/lib/spree_client/models.rb +5 -0
  19. data/lib/spree_client/models/product.rb +7 -0
  20. data/lib/spree_client/models/property.rb +6 -0
  21. data/lib/spree_client/models/stock_item.rb +7 -0
  22. data/lib/spree_client/models/stock_location.rb +7 -0
  23. data/lib/spree_client/models/stock_movement.rb +7 -0
  24. data/lib/spree_client/models/store.rb +7 -0
  25. data/lib/spree_client/models/taxonomy.rb +5 -0
  26. data/lib/spree_client/models/variant.rb +7 -0
  27. metadata +73 -192
  28. data/.gitignore +0 -17
  29. data/.ruby-version +0 -1
  30. data/.travis.yml +0 -11
  31. data/CONTRIBUTING.md +0 -8
  32. data/Gemfile +0 -9
  33. data/LICENSE +0 -22
  34. data/Rakefile +0 -7
  35. data/fixtures/cassette_library/addresss.yml +0 -46
  36. data/fixtures/cassette_library/countries.yml +0 -52
  37. data/fixtures/cassette_library/orders.yml +0 -48
  38. data/fixtures/cassette_library/payments.yml +0 -48
  39. data/fixtures/cassette_library/products.yml +0 -66
  40. data/fixtures/cassette_library/properties.yml +0 -48
  41. data/fixtures/cassette_library/request.yml +0 -46
  42. data/fixtures/cassette_library/return_authorizations.yml +0 -48
  43. data/fixtures/cassette_library/shipment_ready.yml +0 -46
  44. data/fixtures/cassette_library/taxonomies.yml +0 -48
  45. data/fixtures/cassette_library/taxons.yml +0 -48
  46. data/fixtures/cassette_library/variants.yml +0 -63
  47. data/fixtures/cassette_library/zones.yml +0 -49
  48. data/lib/spree-api-client.rb +0 -49
  49. data/lib/spree-api-client/addresses.rb +0 -15
  50. data/lib/spree-api-client/connection.rb +0 -31
  51. data/lib/spree-api-client/countries.rb +0 -15
  52. data/lib/spree-api-client/error.rb +0 -47
  53. data/lib/spree-api-client/line_items.rb +0 -19
  54. data/lib/spree-api-client/orders.rb +0 -32
  55. data/lib/spree-api-client/payments.rb +0 -43
  56. data/lib/spree-api-client/products.rb +0 -31
  57. data/lib/spree-api-client/properties.rb +0 -31
  58. data/lib/spree-api-client/request.rb +0 -56
  59. data/lib/spree-api-client/return_authorizations.rb +0 -31
  60. data/lib/spree-api-client/shipments.rb +0 -15
  61. data/lib/spree-api-client/taxonomies.rb +0 -31
  62. data/lib/spree-api-client/taxons.rb +0 -27
  63. data/lib/spree-api-client/variants.rb +0 -31
  64. data/lib/spree-api-client/version.rb +0 -7
  65. data/lib/spree-api-client/zones.rb +0 -31
  66. data/spec/addresses_spec.rb +0 -12
  67. data/spec/client_spec.rb +0 -32
  68. data/spec/countries_spec.rb +0 -12
  69. data/spec/orders_spec.rb +0 -12
  70. data/spec/payments_spec.rb +0 -12
  71. data/spec/products_spec.rb +0 -12
  72. data/spec/properties_spec.rb +0 -12
  73. data/spec/return_authorizations_spec.rb +0 -12
  74. data/spec/shipments_spec.rb +0 -12
  75. data/spec/spec_helper.rb +0 -10
  76. data/spec/support/vcr.rb +0 -9
  77. data/spec/taxonomies_spec.rb +0 -12
  78. data/spec/taxons_spec.rb +0 -12
  79. data/spec/variants_spec.rb +0 -12
  80. data/spec/zones_spec.rb +0 -12
  81. data/spree-api-client.gemspec +0 -29
@@ -1,48 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:4000/store/api/orders/R781501551/return_authorizations?per_page=30
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 200
21
- message: ! 'OK '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Etag:
28
- - ! '"6f071d405cceb3add2aa1ce45451ae0c"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - f0c2d041caa9e182c835e7dd10c1d87a
33
- X-Runtime:
34
- - '0.074531'
35
- Content-Length:
36
- - '256'
37
- Server:
38
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
39
- Date:
40
- - Fri, 07 Dec 2012 17:37:15 GMT
41
- Connection:
42
- - Keep-Alive
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"count":1,"current_page":1,"pages":1,"return_authorizations":[{"return_authorization":{"id":1,"number":"RMA848788441","state":"authorized","amount":"0.0","order_id":80,"reason":"","created_at":"2012-12-06T11:49:07Z","updated_at":"2012-12-06T11:49:07Z"}}]}'
46
- http_version:
47
- recorded_at: Fri, 07 Dec 2012 17:37:15 GMT
48
- recorded_with: VCR 2.3.0
@@ -1,46 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
5
- uri: http://localhost:4000/store/api/orders/1/shipments/1/ready
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Content-Length:
15
- - '0'
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 404
21
- message: ! 'Not Found '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Cache-Control:
28
- - no-cache
29
- X-Request-Id:
30
- - 10a1c5aac78cf46d9e1e115f95cdf0b2
31
- X-Runtime:
32
- - '0.036787'
33
- Content-Length:
34
- - '67'
35
- Server:
36
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
37
- Date:
38
- - Fri, 07 Dec 2012 17:37:15 GMT
39
- Connection:
40
- - Keep-Alive
41
- body:
42
- encoding: US-ASCII
43
- string: ! '{"error":"translation missing: en-GB.spree.api.resource_not_found"}'
44
- http_version:
45
- recorded_at: Fri, 07 Dec 2012 17:37:15 GMT
46
- recorded_with: VCR 2.3.0
@@ -1,48 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:4000/store/api/taxonomies?per_page=30
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 200
21
- message: ! 'OK '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Etag:
28
- - ! '"6d4a78870b076c5a43e1017631e3a2a5"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - 818109a0d62f745696fad81744dbfd74
33
- X-Runtime:
34
- - '0.141291'
35
- Content-Length:
36
- - '522'
37
- Server:
38
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
39
- Date:
40
- - Fri, 07 Dec 2012 17:37:16 GMT
41
- Connection:
42
- - Keep-Alive
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"count":3,"current_page":1,"pages":1,"taxonomies":[{"taxonomy":{"id":3,"name":"ridebmx","root":{"id":3,"name":"ridebmx","permalink":"ridebmx","position":0,"parent_id":null,"taxonomy_id":3,"taxons":[]}}},{"taxonomy":{"id":1,"name":"rideukbmx","root":{"id":1,"name":"rideukbmx","permalink":"ridebmx","position":0,"parent_id":null,"taxonomy_id":1,"taxons":[]}}},{"taxonomy":{"id":2,"name":"whitelines","root":{"id":2,"name":"whitelines","permalink":"whitelines","position":0,"parent_id":null,"taxonomy_id":2,"taxons":[]}}}]}'
46
- http_version:
47
- recorded_at: Fri, 07 Dec 2012 17:37:16 GMT
48
- recorded_with: VCR 2.3.0
@@ -1,48 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:4000/store/api/taxonomies/1/taxons?per_page=30
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 200
21
- message: ! 'OK '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Etag:
28
- - ! '"d751713988987e9331980363e24189ce"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - 92ea82cb431abd35b20ab737cd348ecd
33
- X-Runtime:
34
- - '0.033542'
35
- Content-Length:
36
- - '2'
37
- Server:
38
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
39
- Date:
40
- - Fri, 07 Dec 2012 17:37:16 GMT
41
- Connection:
42
- - Keep-Alive
43
- body:
44
- encoding: US-ASCII
45
- string: ! '[]'
46
- http_version:
47
- recorded_at: Fri, 07 Dec 2012 17:37:16 GMT
48
- recorded_with: VCR 2.3.0
@@ -1,63 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:4000/store/api/products/1/variants?per_page=30
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 200
21
- message: ! 'OK '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Etag:
28
- - ! '"7ebbeb3d86e3857a26aead46fd50dc24"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - 3ea623d6001a50456a17647ca427e6f5
33
- X-Runtime:
34
- - '0.100396'
35
- Content-Length:
36
- - '9097'
37
- Server:
38
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
39
- Date:
40
- - Fri, 07 Dec 2012 17:37:16 GMT
41
- Connection:
42
- - Keep-Alive
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"count":30,"total_count":30,"current_page":1,"pages":1,"variants":[{"variant":{"id":1,"name":"Bomb","count_on_hand":0,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":"12.99","permalink":"bomb","option_values":[]}},{"variant":{"id":2,"name":"Bomb","count_on_hand":8,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"bomb","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":3,"name":"Bomb","count_on_hand":20,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"bomb","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":4,"name":"Bomb","count_on_hand":14,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"bomb","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":5,"name":"Disobey","count_on_hand":0,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":"12.99","permalink":"disobey","option_values":[]}},{"variant":{"id":6,"name":"Disobey","count_on_hand":10,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"disobey","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":7,"name":"Disobey","count_on_hand":19,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"disobey","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":8,"name":"Disobey","count_on_hand":15,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"disobey","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":9,"name":"POV","count_on_hand":0,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":"12.99","permalink":"pov","option_values":[]}},{"variant":{"id":10,"name":"POV","count_on_hand":10,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"pov","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":11,"name":"POV","count_on_hand":19,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"pov","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":12,"name":"POV","count_on_hand":15,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"pov","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":13,"name":"Bomb","count_on_hand":5,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":"12.99","permalink":"bomb","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":14,"name":"Disobey","count_on_hand":5,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"disobey","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":15,"name":"POV","count_on_hand":5,"sku":"","price":"12.99","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"pov","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":16,"name":"Whitelines
46
- 1","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":null,"permalink":"whitelines-1","option_values":[]}},{"variant":{"id":17,"name":"Whitelines
47
- 1","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-1","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":18,"name":"Whitelines
48
- 1","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-1","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":19,"name":"Whitelines
49
- 1","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-1","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":20,"name":"Whitelines
50
- 1","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-1","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":21,"name":"Whitelines
51
- 2","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":null,"permalink":"whitelines-2","option_values":[]}},{"variant":{"id":22,"name":"Whitelines
52
- 3","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":true,"cost_price":null,"permalink":"whitelines-3","option_values":[]}},{"variant":{"id":23,"name":"Whitelines
53
- 2","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-2","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":24,"name":"Whitelines
54
- 2","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-2","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":25,"name":"Whitelines
55
- 2","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-2","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":26,"name":"Whitelines
56
- 2","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-2","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":27,"name":"Whitelines
57
- 3","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-3","option_values":[{"option_value":{"id":1,"name":"Small","presentation":"Small","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":28,"name":"Whitelines
58
- 3","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-3","option_values":[{"option_value":{"id":2,"name":"Medium","presentation":"Medium","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":29,"name":"Whitelines
59
- 3","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-3","option_values":[{"option_value":{"id":3,"name":"Large","presentation":"Large","option_type_name":"Size","option_type_id":1}}]}},{"variant":{"id":30,"name":"Whitelines
60
- 3","count_on_hand":0,"sku":"","price":"14.0","weight":null,"height":null,"width":null,"depth":null,"is_master":false,"cost_price":null,"permalink":"whitelines-3","option_values":[{"option_value":{"id":4,"name":"XL","presentation":"XL","option_type_name":"Size","option_type_id":1}}]}}]}'
61
- http_version:
62
- recorded_at: Fri, 07 Dec 2012 17:37:16 GMT
63
- recorded_with: VCR 2.3.0
@@ -1,49 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:4000/store/api/zones?per_page=30
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - application/json
12
- X-Spree-Token:
13
- - b56019f04b61a50553ee323f5ab68c6b435871971e79c987
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - Ruby
18
- response:
19
- status:
20
- code: 200
21
- message: ! 'OK '
22
- headers:
23
- Content-Type:
24
- - application/json
25
- X-Ua-Compatible:
26
- - IE=Edge
27
- Etag:
28
- - ! '"c92d758de9ce28cbf25aff60593d11ae"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - 10ac41a5c0639706a64786e46caa8352
33
- X-Runtime:
34
- - '0.199412'
35
- Content-Length:
36
- - '293'
37
- Server:
38
- - WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
39
- Date:
40
- - Fri, 07 Dec 2012 17:37:16 GMT
41
- Connection:
42
- - Keep-Alive
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"count":2,"current_page":1,"pages":1,"zones":[{"zone":{"id":4,"name":"England","description":"","zone_members":[]}},{"zone":{"id":3,"name":"UK","description":"UK","zone_members":[{"zone_member":{"id":1017582645,"name":"United
46
- Kingdom","zoneable_type":"Spree::Country","zoneable_id":213}}]}}]}'
47
- http_version:
48
- recorded_at: Fri, 07 Dec 2012 17:37:16 GMT
49
- recorded_with: VCR 2.3.0
@@ -1,49 +0,0 @@
1
- require 'faraday_middleware'
2
- require "spree-api-client/version"
3
-
4
- require 'spree-api-client/connection'
5
- require 'spree-api-client/request'
6
-
7
- require 'spree-api-client/products'
8
- require 'spree-api-client/variants'
9
- require 'spree-api-client/orders'
10
- require 'spree-api-client/taxonomies'
11
- require 'spree-api-client/addresses'
12
- require 'spree-api-client/countries'
13
- require 'spree-api-client/zones'
14
- require 'spree-api-client/properties'
15
- require 'spree-api-client/line_items'
16
- require 'spree-api-client/return_authorizations'
17
- require 'spree-api-client/taxons'
18
- require 'spree-api-client/payments'
19
- require 'spree-api-client/shipments'
20
-
21
- module Spree
22
- module API
23
- class Client
24
- include Spree::API::Client::Connection
25
- include Spree::API::Client::Request
26
-
27
- include Spree::API::Client::Products
28
- include Spree::API::Client::Variants
29
- include Spree::API::Client::Orders
30
- include Spree::API::Client::Taxonomies
31
- include Spree::API::Client::Addresses
32
- include Spree::API::Client::Countries
33
- include Spree::API::Client::Zones
34
- include Spree::API::Client::Properties
35
- include Spree::API::Client::LineItems
36
- include Spree::API::Client::ReturnAuthorizations
37
- include Spree::API::Client::Taxons
38
- include Spree::API::Client::Payments
39
- include Spree::API::Client::Shipments
40
-
41
- attr_accessor :api_endpoint, :api_token, :per_page
42
- def initialize(api_endpoint, api_token, options={})
43
- @api_endpoint = api_endpoint
44
- @api_token = api_token
45
- @per_page = options.fetch(:per_page, 30)
46
- end
47
- end
48
- end
49
- end
@@ -1,15 +0,0 @@
1
- module Spree
2
- module API
3
- class Client
4
- module Addresses
5
- def address(id, options={})
6
- get("addresses/#{id}", options)
7
- end
8
-
9
- def update_address(id, options={})
10
- put("addresses/#{id}", options)
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,31 +0,0 @@
1
- module Spree
2
- module API
3
- class Client
4
- module Connection
5
- def connection(options={})
6
- options = {
7
- :authenticate => true,
8
- :force_urlencoded => false,
9
- :raw => false,
10
- :ssl => { :verify => false },
11
- :url => api_endpoint,
12
- :path_prefix => '/api'
13
- }.merge(options)
14
-
15
- connection = Faraday.new(options) do |builder|
16
- builder.request :json
17
-
18
- builder.use FaradayMiddleware::FollowRedirects
19
- builder.use FaradayMiddleware::Mashify
20
- builder.use Faraday::Response::RaiseError
21
-
22
- builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
23
-
24
- builder.adapter Faraday.default_adapter
25
- end
26
- connection
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,15 +0,0 @@
1
- module Spree
2
- module API
3
- class Client
4
- module Countries
5
- def countries(options={})
6
- get("countries", options)['countries']
7
- end
8
-
9
- def country(id, options={})
10
- get("countries/#{id}", options)
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,47 +0,0 @@
1
- module Spree
2
- module API
3
- class Client
4
- class Error < StandardError
5
-
6
- # Raised when Spree returns a 4xx or 500 HTTP status code
7
- class ClientError < Error
8
-
9
- # Creates a new error from an HTTP environement
10
- #
11
- # @param error [Exception]
12
- # @return [Spree::API::Client::Error::ClientError]
13
- def initialize(error=nil)
14
- if error.respond_to?(:response) && !error.response.nil?
15
- http_error = error.response[:status].to_i
16
-
17
- if ERROR_MAP.has_key?(http_error)
18
- raise ERROR_MAP[http_error].new(
19
- message: error.response[:body]["error"],
20
- validation_errors: error.response[:body]["errors"] || error.response[:body]["exception"])
21
- else
22
- super
23
- end
24
- else
25
- super
26
- end
27
- end
28
- end # ClientError
29
-
30
- # Raised when Spree returns a 401 HTTP status code
31
- class Unauthorized < Error; end
32
-
33
- # Raised when Spree returns a 404 HTTP status code
34
- class NotFound < Error; end
35
-
36
- # Raised when Spree returns a 422 HTTP status code
37
- class UnprocessableEntity < Error; end
38
-
39
- ERROR_MAP = {
40
- 401 => Spree::API::Client::Error::Unauthorized,
41
- 404 => Spree::API::Client::Error::NotFound,
42
- 422 => Spree::API::Client::Error::UnprocessableEntity
43
- }
44
- end # Error
45
- end
46
- end
47
- end