veeqo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.hound.yml +3 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +629 -0
  6. data/.sample.pryrc +4 -0
  7. data/.travis.yml +5 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +574 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +10 -0
  13. data/bin/rspec +17 -0
  14. data/bin/setup +8 -0
  15. data/lib/veeqo.rb +16 -0
  16. data/lib/veeqo/actions/base.rb +13 -0
  17. data/lib/veeqo/actions/delete.rb +11 -0
  18. data/lib/veeqo/actions/find.rb +11 -0
  19. data/lib/veeqo/actions/list.rb +11 -0
  20. data/lib/veeqo/allocation.rb +32 -0
  21. data/lib/veeqo/base.rb +26 -0
  22. data/lib/veeqo/company.rb +17 -0
  23. data/lib/veeqo/configuration.rb +17 -0
  24. data/lib/veeqo/customer.rb +24 -0
  25. data/lib/veeqo/delivery_method.rb +19 -0
  26. data/lib/veeqo/errors.rb +30 -0
  27. data/lib/veeqo/errors/forbidden.rb +9 -0
  28. data/lib/veeqo/errors/request_error.rb +15 -0
  29. data/lib/veeqo/errors/server_error.rb +9 -0
  30. data/lib/veeqo/errors/unauthorized.rb +9 -0
  31. data/lib/veeqo/order.rb +25 -0
  32. data/lib/veeqo/product.rb +25 -0
  33. data/lib/veeqo/purchase_order.rb +11 -0
  34. data/lib/veeqo/request.rb +89 -0
  35. data/lib/veeqo/response.rb +27 -0
  36. data/lib/veeqo/shipment.rb +30 -0
  37. data/lib/veeqo/store.rb +19 -0
  38. data/lib/veeqo/supplier.rb +19 -0
  39. data/lib/veeqo/version.rb +3 -0
  40. data/lib/veeqo/warehouse.rb +19 -0
  41. data/spec/fixtures/allocation_created.json +554 -0
  42. data/spec/fixtures/company.json +3 -0
  43. data/spec/fixtures/customer.json +4 -0
  44. data/spec/fixtures/customer_created.json +15 -0
  45. data/spec/fixtures/customers.json +38 -0
  46. data/spec/fixtures/delivery_method.json +3 -0
  47. data/spec/fixtures/delivery_method_created.json +4 -0
  48. data/spec/fixtures/delivery_methods.json +5 -0
  49. data/spec/fixtures/empty.json +0 -0
  50. data/spec/fixtures/order.json +3 -0
  51. data/spec/fixtures/order_created.json +554 -0
  52. data/spec/fixtures/orders.json +5 -0
  53. data/spec/fixtures/ping.json +3 -0
  54. data/spec/fixtures/product.json +4 -0
  55. data/spec/fixtures/product_created.json +137 -0
  56. data/spec/fixtures/products.json +5 -0
  57. data/spec/fixtures/purchase_orders.json +177 -0
  58. data/spec/fixtures/shipment_created.json +19 -0
  59. data/spec/fixtures/store.json +3 -0
  60. data/spec/fixtures/store_created.json +4 -0
  61. data/spec/fixtures/stores.json +5 -0
  62. data/spec/fixtures/supplier.json +3 -0
  63. data/spec/fixtures/supplier_created.json +4 -0
  64. data/spec/fixtures/suppliers.json +5 -0
  65. data/spec/fixtures/warehouse.json +3 -0
  66. data/spec/fixtures/warehouse_created.json +4 -0
  67. data/spec/fixtures/warehouses.json +5 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/fake_veeqo_api.rb +408 -0
  70. data/spec/veeqo/actions/list_spec.rb +38 -0
  71. data/spec/veeqo/allocation_spec.rb +49 -0
  72. data/spec/veeqo/base_spec.rb +23 -0
  73. data/spec/veeqo/company_spec.rb +23 -0
  74. data/spec/veeqo/configuration_spec.rb +24 -0
  75. data/spec/veeqo/customer_spec.rb +77 -0
  76. data/spec/veeqo/delivery_method_spec.rb +65 -0
  77. data/spec/veeqo/order_spec.rb +93 -0
  78. data/spec/veeqo/product_spec.rb +82 -0
  79. data/spec/veeqo/purchase_order_spec.rb +14 -0
  80. data/spec/veeqo/request_spec.rb +40 -0
  81. data/spec/veeqo/shipment_spec.rb +38 -0
  82. data/spec/veeqo/store_spec.rb +61 -0
  83. data/spec/veeqo/supplier_spec.rb +61 -0
  84. data/spec/veeqo/warehouse_spec.rb +61 -0
  85. data/veeqo.gemspec +26 -0
  86. metadata +198 -0
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::PurchaseOrder do
4
+ describe ".list" do
5
+ it "retrieves the list of purchase orders" do
6
+ filter_hash = { page: 2, page_size: 10 }
7
+ stub_veeqo_purchase_order_list_api(filter_hash)
8
+ purchase_orders = Veeqo::PurchaseOrder.list(filter_hash)
9
+
10
+ expect(purchase_orders.count).to eq(1)
11
+ expect(purchase_orders.first.id).not_to be_nil
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::Request do
4
+ describe "#run" do
5
+ context "with 2xx response" do
6
+ it "retrieves a resource via specified http verb" do
7
+ stub_ping_request_via_get
8
+ response = Veeqo::Request.new(:get, "ping").run
9
+
10
+ expect(response.code.to_i).to eq(200)
11
+ end
12
+ end
13
+
14
+ context "with 4xx, 5xx response" do
15
+ it "raises the proper response error" do
16
+ stub_invalid_ping_request_via_get
17
+ request = Veeqo::Request.new(:get, "invalid")
18
+
19
+ expect { request.run }.to raise_error(Veeqo::Errors::ServerError)
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#parse" do
25
+ it "runs the request and parse the response" do
26
+ stub_ping_request_via_get
27
+ response = Veeqo::Request.new(:get, "ping").parse
28
+
29
+ expect(response.data).to eq("Pong!")
30
+ end
31
+ end
32
+
33
+ def stub_ping_request_via_get
34
+ stub_api_response(:get, "ping", status: 200, filename: "ping")
35
+ end
36
+
37
+ def stub_invalid_ping_request_via_get
38
+ stub_api_response(:get, "invalid", status: 503, filename: "ping")
39
+ end
40
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::Shipment do
4
+ describe ".create" do
5
+ it "creates a new shipment" do
6
+ stub_veeqo_shipment_create_api(shipment_attributes)
7
+ shipment = Veeqo::Shipment.create(shipment_attributes)
8
+
9
+ expect(shipment.id).not_to be_nil
10
+ expect(shipment.order_id).to eq(shipment_attributes[:order_id])
11
+ expect(shipment.allocation_id).to eq(shipment_attributes[:allocation_id])
12
+ end
13
+ end
14
+
15
+ describe ".delete" do
16
+ it "deletes a spcified shipment" do
17
+ shipment_id = 123
18
+
19
+ stub_veeqo_shipment_delete_api(shipment_id)
20
+ shipment_deletion = Veeqo::Shipment.delete(shipment_id)
21
+
22
+ expect(shipment_deletion.successful?).to be_truthy
23
+ end
24
+ end
25
+
26
+ def shipment_attributes
27
+ {
28
+ order_id: 1,
29
+ allocation_id: 1,
30
+ shipment: {
31
+ carrier_id: 3,
32
+ notify_customer: false,
33
+ update_remote_order: false,
34
+ tracking_number: "12345679ABC",
35
+ },
36
+ }
37
+ end
38
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::Store do
4
+ describe ".list" do
5
+ it "retrieves all the stores" do
6
+ filters = { page: 1, page_size: 12 }
7
+
8
+ stub_veeqo_store_list_api(filters)
9
+ stores = Veeqo::Store.list(filters)
10
+
11
+ expect(stores.count).to eq(1)
12
+ expect(stores.first.id).to eq(123)
13
+ end
14
+ end
15
+
16
+ describe ".find" do
17
+ it "retrieves the details for a store" do
18
+ store_id = 123
19
+
20
+ stub_veeqo_store_find_api(store_id)
21
+ store = Veeqo::Store.find(store_id)
22
+
23
+ expect(store.name).not_to be_nil
24
+ end
25
+ end
26
+
27
+ describe ".create" do
28
+ it "creates a new store" do
29
+ store_attributes = { name: "Phone", type_code: "direct" }
30
+
31
+ stub_veeqo_store_create_api(store_attributes)
32
+ store = Veeqo::Store.create(store_attributes)
33
+
34
+ expect(store.id).not_to be_nil
35
+ expect(store.name).to eq(store_attributes[:name])
36
+ end
37
+ end
38
+
39
+ describe ".update" do
40
+ it "updates the store with new attributes" do
41
+ store_id = 123
42
+ new_attributes = { name: "Phone" }
43
+
44
+ stub_veeqo_store_update_api(store_id, new_attributes)
45
+ store_update = Veeqo::Store.update(store_id, new_attributes)
46
+
47
+ expect(store_update.successful?).to be_truthy
48
+ end
49
+ end
50
+
51
+ describe ".delete" do
52
+ it "deletes the specified store" do
53
+ store_id = 123
54
+
55
+ stub_veeqo_store_delete_api(store_id)
56
+ store_deletion = Veeqo::Store.delete(store_id)
57
+
58
+ expect(store_deletion.successful?).to be_truthy
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::Supplier do
4
+ describe ".list" do
5
+ it "retrieves the list of suppliers" do
6
+ filters = { page: 1, page_size: 12 }
7
+
8
+ stub_veeqo_supplier_list_api(filters)
9
+ suppliers = Veeqo::Supplier.list(filters)
10
+
11
+ expect(suppliers.count).to eq(1)
12
+ expect(suppliers.first.id).not_to be_nil
13
+ end
14
+ end
15
+
16
+ describe ".find" do
17
+ it "retrieves the supplier details" do
18
+ supplier_id = 123
19
+
20
+ stub_veeqo_supplier_find_api(supplier_id)
21
+ supplier = Veeqo::Supplier.find(supplier_id)
22
+
23
+ expect(supplier.name).to eq("ACME")
24
+ end
25
+ end
26
+
27
+ describe ".create" do
28
+ it "creates a new supplier" do
29
+ supplier_attributes = { name: "ACME" }
30
+
31
+ stub_veeqo_supplier_create_api(supplier_attributes)
32
+ supplier = Veeqo::Supplier.create(supplier_attributes)
33
+
34
+ expect(supplier.id).not_to be_nil
35
+ expect(supplier.name).to eq(supplier_attributes[:name])
36
+ end
37
+ end
38
+
39
+ describe ".update" do
40
+ it "updates the supplier with new attributes" do
41
+ supplier_id = 123
42
+ new_attributes = { name: "ACME" }
43
+
44
+ stub_veeqo_supplier_update_api(supplier_id, new_attributes)
45
+ supplier_update = Veeqo::Supplier.update(supplier_id, new_attributes)
46
+
47
+ expect(supplier_update.successful?).to be_truthy
48
+ end
49
+ end
50
+
51
+ describe ".delete" do
52
+ it "deletes the specified supplier" do
53
+ supplier_id = 123
54
+
55
+ stub_veeqo_supplier_delete_api(supplier_id)
56
+ supplier_delete = Veeqo::Supplier.delete(supplier_id)
57
+
58
+ expect(supplier_delete.successful?).to be_truthy
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Veeqo::Warehouse do
4
+ describe ".list" do
5
+ it "retrieves the list of warehouses" do
6
+ filters = { page: 1, page_size: 12 }
7
+
8
+ stub_veeqo_warehouse_list_api(filters)
9
+ warehouses = Veeqo::Warehouse.list(filters)
10
+
11
+ expect(warehouses.count).to eq(1)
12
+ expect(warehouses.first.id).not_to be_nil
13
+ end
14
+ end
15
+
16
+ describe ".find" do
17
+ it "retrieves the specific warehouse details" do
18
+ warehouse_id = 123
19
+
20
+ stub_veeqo_warehouse_find_api(warehouse_id)
21
+ warehouse = Veeqo::Warehouse.find(warehouse_id)
22
+
23
+ expect(warehouse.name).not_to be_nil
24
+ end
25
+ end
26
+
27
+ describe ".create" do
28
+ it "creates a new warehouse" do
29
+ warehouse_attributes = { name: "My Warehouse" }
30
+
31
+ stub_veeqo_warehouse_create_api(warehouse_attributes)
32
+ warehouse = Veeqo::Warehouse.create(warehouse_attributes)
33
+
34
+ expect(warehouse.id).not_to be_nil
35
+ expect(warehouse.name).to eq(warehouse_attributes[:name])
36
+ end
37
+ end
38
+
39
+ describe ".update" do
40
+ it "updates a warehouse with new attributes" do
41
+ warehouse_id = 123
42
+ new_attributes = { name: "My Warehouse" }
43
+
44
+ stub_veeqo_warehouse_update_api(warehouse_id, new_attributes)
45
+ warehouse_update = Veeqo::Warehouse.update(warehouse_id, new_attributes)
46
+
47
+ expect(warehouse_update.successful?).to be_truthy
48
+ end
49
+ end
50
+
51
+ describe ".delete" do
52
+ it "deletes the specified warehouse" do
53
+ warehouse_id = 123
54
+
55
+ stub_veeqo_warehouse_delete_api(warehouse_id)
56
+ warehouse_deletion = Veeqo::Warehouse.delete(warehouse_id)
57
+
58
+ expect(warehouse_deletion.successful?).to be_truthy
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "veeqo/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "veeqo"
8
+ spec.version = Veeqo::VERSION
9
+ spec.authors = ["Abu Nashir"]
10
+ spec.email = ["abunashir@gmail.com"]
11
+
12
+ spec.summary = %q{The Ruby Interface to the Veeqo API}
13
+ spec.description = %q{The Ruby Interface to the Veeqo API}
14
+ spec.homepage = "https://www.veeqo.com/"
15
+ spec.license = "MIT"
16
+
17
+ spec.require_paths = ["lib"]
18
+ spec.files = `git ls-files`.split("\n")
19
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.13"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "webmock", "~> 2.0"
25
+ spec.add_development_dependency "pry", "~> 0.10.3"
26
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veeqo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Abu Nashir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.3
83
+ description: The Ruby Interface to the Veeqo API
84
+ email:
85
+ - abunashir@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".hound.yml"
92
+ - ".rspec"
93
+ - ".rubocop.yml"
94
+ - ".sample.pryrc"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/rspec
102
+ - bin/setup
103
+ - lib/veeqo.rb
104
+ - lib/veeqo/actions/base.rb
105
+ - lib/veeqo/actions/delete.rb
106
+ - lib/veeqo/actions/find.rb
107
+ - lib/veeqo/actions/list.rb
108
+ - lib/veeqo/allocation.rb
109
+ - lib/veeqo/base.rb
110
+ - lib/veeqo/company.rb
111
+ - lib/veeqo/configuration.rb
112
+ - lib/veeqo/customer.rb
113
+ - lib/veeqo/delivery_method.rb
114
+ - lib/veeqo/errors.rb
115
+ - lib/veeqo/errors/forbidden.rb
116
+ - lib/veeqo/errors/request_error.rb
117
+ - lib/veeqo/errors/server_error.rb
118
+ - lib/veeqo/errors/unauthorized.rb
119
+ - lib/veeqo/order.rb
120
+ - lib/veeqo/product.rb
121
+ - lib/veeqo/purchase_order.rb
122
+ - lib/veeqo/request.rb
123
+ - lib/veeqo/response.rb
124
+ - lib/veeqo/shipment.rb
125
+ - lib/veeqo/store.rb
126
+ - lib/veeqo/supplier.rb
127
+ - lib/veeqo/version.rb
128
+ - lib/veeqo/warehouse.rb
129
+ - spec/fixtures/allocation_created.json
130
+ - spec/fixtures/company.json
131
+ - spec/fixtures/customer.json
132
+ - spec/fixtures/customer_created.json
133
+ - spec/fixtures/customers.json
134
+ - spec/fixtures/delivery_method.json
135
+ - spec/fixtures/delivery_method_created.json
136
+ - spec/fixtures/delivery_methods.json
137
+ - spec/fixtures/empty.json
138
+ - spec/fixtures/order.json
139
+ - spec/fixtures/order_created.json
140
+ - spec/fixtures/orders.json
141
+ - spec/fixtures/ping.json
142
+ - spec/fixtures/product.json
143
+ - spec/fixtures/product_created.json
144
+ - spec/fixtures/products.json
145
+ - spec/fixtures/purchase_orders.json
146
+ - spec/fixtures/shipment_created.json
147
+ - spec/fixtures/store.json
148
+ - spec/fixtures/store_created.json
149
+ - spec/fixtures/stores.json
150
+ - spec/fixtures/supplier.json
151
+ - spec/fixtures/supplier_created.json
152
+ - spec/fixtures/suppliers.json
153
+ - spec/fixtures/warehouse.json
154
+ - spec/fixtures/warehouse_created.json
155
+ - spec/fixtures/warehouses.json
156
+ - spec/spec_helper.rb
157
+ - spec/support/fake_veeqo_api.rb
158
+ - spec/veeqo/actions/list_spec.rb
159
+ - spec/veeqo/allocation_spec.rb
160
+ - spec/veeqo/base_spec.rb
161
+ - spec/veeqo/company_spec.rb
162
+ - spec/veeqo/configuration_spec.rb
163
+ - spec/veeqo/customer_spec.rb
164
+ - spec/veeqo/delivery_method_spec.rb
165
+ - spec/veeqo/order_spec.rb
166
+ - spec/veeqo/product_spec.rb
167
+ - spec/veeqo/purchase_order_spec.rb
168
+ - spec/veeqo/request_spec.rb
169
+ - spec/veeqo/shipment_spec.rb
170
+ - spec/veeqo/store_spec.rb
171
+ - spec/veeqo/supplier_spec.rb
172
+ - spec/veeqo/warehouse_spec.rb
173
+ - veeqo.gemspec
174
+ homepage: https://www.veeqo.com/
175
+ licenses:
176
+ - MIT
177
+ metadata: {}
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 2.6.4
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: The Ruby Interface to the Veeqo API
198
+ test_files: []