ecwid_api 0.0.2 → 0.2.3

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.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +8 -0
  3. data/README.md +123 -31
  4. data/ecwid_api.gemspec +10 -8
  5. data/lib/ecwid_api.rb +18 -29
  6. data/lib/ecwid_api/api.rb +12 -0
  7. data/lib/ecwid_api/api/base.rb +18 -0
  8. data/lib/ecwid_api/api/categories.rb +56 -0
  9. data/lib/ecwid_api/api/customers.rb +53 -0
  10. data/lib/ecwid_api/api/orders.rb +36 -0
  11. data/lib/ecwid_api/api/product_combinations.rb +48 -0
  12. data/lib/ecwid_api/api/product_types.rb +56 -0
  13. data/lib/ecwid_api/api/products.rb +148 -0
  14. data/lib/ecwid_api/category.rb +53 -4
  15. data/lib/ecwid_api/client.rb +65 -58
  16. data/lib/ecwid_api/customer.rb +10 -0
  17. data/lib/ecwid_api/entity.rb +151 -29
  18. data/lib/ecwid_api/error.rb +10 -0
  19. data/lib/ecwid_api/o_auth.rb +106 -0
  20. data/lib/ecwid_api/order.rb +118 -0
  21. data/lib/ecwid_api/order_item.rb +17 -0
  22. data/lib/ecwid_api/paged_ecwid_response.rb +57 -0
  23. data/lib/ecwid_api/paged_enumerator.rb +66 -0
  24. data/lib/ecwid_api/person.rb +7 -0
  25. data/lib/ecwid_api/product.rb +65 -0
  26. data/lib/ecwid_api/product_combination.rb +30 -0
  27. data/lib/ecwid_api/product_type.rb +18 -0
  28. data/lib/ecwid_api/product_type_attribute.rb +27 -0
  29. data/lib/ecwid_api/unpaged_ecwid_response.rb +38 -0
  30. data/lib/ecwid_api/version.rb +1 -1
  31. data/lib/ext/string.rb +9 -1
  32. data/spec/api/categories_spec.rb +31 -0
  33. data/spec/api/customers_spec.rb +20 -0
  34. data/spec/api/orders_spec.rb +30 -0
  35. data/spec/api/product_types_spec.rb +20 -0
  36. data/spec/api/products_spec.rb +20 -0
  37. data/spec/category_spec.rb +1 -6
  38. data/spec/client_spec.rb +4 -32
  39. data/spec/entity_spec.rb +120 -8
  40. data/spec/fixtures/categories.json +28 -22
  41. data/spec/fixtures/classes.json +44 -0
  42. data/spec/fixtures/customers.json +48 -0
  43. data/spec/fixtures/order.json +162 -0
  44. data/spec/fixtures/orders.json +303 -0
  45. data/spec/fixtures/products.json +141 -0
  46. data/spec/helpers/client.rb +34 -0
  47. data/spec/oauth_spec.rb +40 -0
  48. data/spec/order_item_spec.rb +12 -0
  49. data/spec/order_spec.rb +71 -0
  50. data/spec/paged_enumerator_spec.rb +38 -0
  51. data/spec/spec_helper.rb +3 -3
  52. metadata +93 -37
  53. data/lib/ecwid_api/category_api.rb +0 -62
  54. data/spec/category_api_spec.rb +0 -36
  55. data/spec/ecwid_api_spec.rb +0 -15
  56. data/spec/helpers/faraday.rb +0 -30
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EcwidApi::CategoryApi, faraday: true do
4
- let(:client) { EcwidApi::Client.new { |config| config.store_id = '12345' } }
5
- subject { EcwidApi::CategoryApi.new(client) }
6
-
7
- before(:each) do
8
- faraday_client(client)
9
- end
10
-
11
- describe "#all" do
12
- it "gets all of the categories from the client" do
13
- expect(client).to receive(:get).with("categories", {}).and_call_original
14
- subject.all
15
- end
16
-
17
- it "gets sub categories" do
18
- expect(client).to receive(:get).with("categories", parent: 5).and_call_original
19
- subject.all(5)
20
- end
21
- end
22
-
23
- describe "#root" do
24
- it "gets the root level categories" do
25
- expect(subject).to receive(:all).with(0).and_call_original
26
- subject.root
27
- end
28
- end
29
-
30
- describe "#find" do
31
- it "finds a single category" do
32
- expect(client).to receive(:get).with("category", id: 5).and_call_original
33
- subject.find(5)
34
- end
35
- end
36
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe EcwidApi do
4
- describe "::default_client" do
5
- it "builds an EcwidApi::Client with the block" do
6
- EcwidApi.default_client.should be_nil
7
-
8
- client = EcwidApi.default_client do |config|
9
- config.store_id = 123
10
- end
11
-
12
- client.is_a?(EcwidApi::Client).should be_true
13
- end
14
- end
15
- end
@@ -1,30 +0,0 @@
1
- require 'faraday'
2
-
3
- module Helpers
4
- module Faraday
5
- def fixtures
6
- %w(categories category)
7
- end
8
-
9
- def faraday_stubs
10
- ::Faraday::Adapter::Test::Stubs.new do |stub|
11
- fixtures.each do |fixture|
12
- stub.get(fixture) { [ 200, {"Content-Type" => "application/json"}, File.read("spec/fixtures/#{fixture}.json") ] }
13
- end
14
- end
15
- end
16
-
17
- # Public: Returns a test Faraday::Connection
18
- def faraday
19
- ::Faraday.new do |builder|
20
- builder.response :json, content_type: /\bjson$/
21
- builder.adapter :test, faraday_stubs
22
- end
23
- end
24
-
25
- # Public: Uses the Faraday stub connection with the client
26
- def faraday_client(client)
27
- allow(client).to receive(:connection).and_return(faraday)
28
- end
29
- end
30
- end