veeqo_api_ruby 0.2.2 → 0.3.0

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: 4ec25fe807f27f4e40bb903d914757c17a755285
4
- data.tar.gz: 2869d1d72094c5534d62e9d9265f32359d301d3b
3
+ metadata.gz: 5cf3b67027ebfec13af0469c401ab940ec7987aa
4
+ data.tar.gz: 486445cebc519706afe0264b21740f55805860c5
5
5
  SHA512:
6
- metadata.gz: 0e343ad817ba2eb30e311290b090576ad10fb795f07f09ea283ed74ea07620dbe946570cb6a2b6c532a3e3cdb362e1b1283dcffd5260ba06809cbf6d04620711
7
- data.tar.gz: 2920713e83656d60e2ea665aead6efc33a697c493cfb18a06fee9bfd07c96cf5daed871594f2072429186d964100bece063386b3c70cdc0c166891fc769aed09
6
+ metadata.gz: f4003cea81aa122e13e4677ced2d225b99a7b2ea60ed3def4201453e0913196fe58089ffd91ee177b052d0211832dd7d27b7ce2e810ca7a47029d1b8e48b7b1a
7
+ data.tar.gz: 9d84d4760e10b0a27f5565f903bed70170505c21c6d614d7155ced2f39302080f63d1722aaa7bd94b3f42ba9bee4646f301089473ae3f180c01726757bf865c5
@@ -1,4 +1,5 @@
1
1
  require 'hashie'
2
+ require 'oj'
2
3
  require 'faraday_middleware'
3
4
  require 'veeqo/version'
4
5
  require 'veeqo/config'
@@ -44,7 +44,7 @@ module Veeqo
44
44
  response_headers = {}
45
45
  unless env.body.empty?
46
46
  response_headers = begin
47
- JSON.parse(env.body, symbolize_names: true)
47
+ Oj.load(env.body, symbol_keys: true)
48
48
  rescue
49
49
  {}
50
50
  end
@@ -8,6 +8,7 @@ module Veeqo
8
8
 
9
9
  def call(env)
10
10
  env[:request_headers]['x-api-key'] = @options[:api_key]
11
+ env[:request_headers]['x-api-request'] = 'true'
11
12
  @app.call env
12
13
  end
13
14
  end
@@ -50,7 +50,8 @@ module Veeqo
50
50
 
51
51
  def delete(path, params = {})
52
52
  response = raw_request(:delete, path, params)
53
- response.body
53
+ return response.body if response.body.empty?
54
+ build_response_object response
54
55
  end
55
56
 
56
57
  def post(path, params = {})
@@ -63,6 +64,11 @@ module Veeqo
63
64
  build_response_object response
64
65
  end
65
66
 
67
+ def quantity(path, params = {})
68
+ response = raw_request(:get, path, params)
69
+ response.headers['X-Total-Count'].to_i
70
+ end
71
+
66
72
  def raw_request(method, path, params = {})
67
73
  client = params.delete(:connection) || Veeqo.api
68
74
  client.send(method, path.to_s, params)
@@ -81,7 +87,7 @@ module Veeqo
81
87
 
82
88
  def parse(json)
83
89
  return [] if json.empty?
84
- JSON.parse(json, symbolize_names: true)
90
+ Oj.load(json, symbol_keys: true)
85
91
  end
86
92
  end
87
93
  end
@@ -4,19 +4,21 @@ module Veeqo
4
4
 
5
5
  def initialize(options = {})
6
6
  @options = options
7
- tap do |mod|
8
- mod.define_singleton_method :_options do
9
- mod.options
10
- end
7
+ define_singleton_method :_options do
8
+ options
11
9
  end
12
10
  end
13
11
 
14
12
  def included(base)
15
13
  base.send(:include, Request.new(options[:uri]))
16
14
  base.extend(ClassMethods)
17
- options[:disable_methods] ||= []
18
- methods = ClassMethods.public_instance_methods & options[:disable_methods]
19
- methods.each { |name| base.send(:remove_method, name) }
15
+ options[:disable] ||= []
16
+ methods = ClassMethods.public_instance_methods & options[:disable]
17
+ class << base
18
+ self
19
+ end.class_eval do
20
+ methods.each { |filtered_name| undef_method filtered_name }
21
+ end
20
22
  end
21
23
 
22
24
  module ClassMethods
@@ -46,6 +48,10 @@ module Veeqo
46
48
  def destroy_all(params = {})
47
49
  delete path.build, params
48
50
  end
51
+
52
+ def count(params = {})
53
+ quantity path.build, params
54
+ end
49
55
  end
50
56
  end
51
57
  end
@@ -0,0 +1,65 @@
1
+ # Allocations
2
+ # Resources related to the allocations in the API.
3
+ # http://docs.veeqo.apiary.io/#reference/allocations/allocation-collection/create-a-new-allocation
4
+
5
+ module Veeqo
6
+ class Allocation < Resource
7
+ include Veeqo::SubresourceActions.new(uri: 'orders/%d/allocations/%d', disable: %i[destroy_all all find])
8
+
9
+ property :id
10
+ property :additional_order_level_taxless_discount
11
+ property :allocated_completely
12
+ property :allocations
13
+ property :allocated_by_id
14
+ property :buyer_user_id
15
+ property :cancel_reason
16
+ property :cancelled_at
17
+ property :cancelled_by
18
+ property :channel
19
+ property :created_at
20
+ property :created_by
21
+ property :customer
22
+ property :customer_note
23
+ property :customer_viewable_notes
24
+ property :deliver_to
25
+ property :delivery_cost
26
+ property :delivery_method
27
+ property :due_date
28
+ property :employee_notes
29
+ property :fulfilled_by_amazon
30
+ property :fulfillment_channel_order
31
+ property :international
32
+ property :is_amazon_premium_order
33
+ property :is_amazon_prime
34
+ property :line_items
35
+ property :matched_parcel_properties_criteria
36
+ property :notes
37
+ property :number
38
+ property :order_id
39
+ property :packed_completely
40
+ property :payment
41
+ property :picked_completely
42
+ property :receipt_printed
43
+ property :recommended_shipping_options
44
+ property :refund_amount
45
+ property :restock_shipped_items
46
+ property :returns
47
+ property :send_notification_email
48
+ property :send_refund_email
49
+ property :shipment
50
+ property :shipped_at
51
+ property :status
52
+ property :subtotal_price
53
+ property :tags
54
+ property :till_id
55
+ property :total_discounts
56
+ property :total_fees
57
+ property :total_price
58
+ property :total_tax
59
+ property :total_weight
60
+ property :updated_at
61
+ property :updated_by
62
+ property :weight_unit
63
+ property :warehouse
64
+ end
65
+ end
@@ -1,6 +1,6 @@
1
1
  # Channels
2
2
  # Resources related to the channels in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/channels
3
+ # http://docs.veeqo.apiary.io/#reference/stores/store-collection/list-all-stores
4
4
 
5
5
  module Veeqo
6
6
  class Channel < Resource
@@ -1,6 +1,6 @@
1
1
  # Company
2
2
  # Metadata that describes the Company.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/company
3
+ # http://docs.veeqo.apiary.io/#reference/company/company/view-company-detail
4
4
 
5
5
  module Veeqo
6
6
  class Company < Resource
@@ -1,10 +1,10 @@
1
1
  # customers
2
2
  # Resources related to the customers in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/customers
3
+ # http://docs.veeqo.apiary.io/#reference/customers/customer-collection/list-all-customers
4
4
 
5
5
  module Veeqo
6
6
  class Customer < Resource
7
- include Veeqo::ResourceActions.new(uri: 'customers/%d', disable: [:destroy, :destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'customers/%d', disable: %i[destroy destroy_all])
8
8
 
9
9
  property :id
10
10
  property :email
@@ -1,10 +1,10 @@
1
1
  # DeliveryMethods
2
2
  # Resources related to the DeliveryMethods in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/delivery_methods
3
+ # http://docs.veeqo.apiary.io/#reference/delivery-methods/delivery-methods-collection/list-all-delivery-methods
4
4
 
5
5
  module Veeqo
6
6
  class DeliveryMethod < Resource
7
- include Veeqo::ResourceActions.new(uri: 'delivery_methods/%d', disable: [:destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'delivery_methods/%d', disable: %i[destroy_all count])
8
8
 
9
9
  property :id
10
10
  property :cost
@@ -1,10 +1,10 @@
1
1
  # Orders
2
2
  # Resources related to the orders in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/orders
3
+ # http://docs.veeqo.apiary.io/#reference/orders/order-collection
4
4
 
5
5
  module Veeqo
6
6
  class Order < Resource
7
- include Veeqo::ResourceActions.new(uri: 'orders/%d', disable: [:destroy, :destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'orders/%d', disable: %i[destroy destroy_all])
8
8
 
9
9
  property :id
10
10
  property :allocated_completely
@@ -48,11 +48,9 @@ module Veeqo
48
48
  property :updated_at
49
49
  property :updated_by
50
50
 
51
- def self.destroy(resource_id, params = {})
52
- raise ArgumentError if resource_id.nil?
53
- delete path.build(resource_id), params
54
- rescue Veeqo::NotFound
55
- nil
51
+ def self.bulk_tagging(resource_ids, tag_ids, params = {})
52
+ raise ArgumentError if resource_ids.empty? || tag_ids.empty?
53
+ post 'https://app.veeqo.com/bulk_tagging', { order_ids: [*resource_ids], tag_ids: [*tag_ids] }.merge(params)
56
54
  end
57
55
  end
58
56
  end
@@ -1,6 +1,6 @@
1
1
  # Products
2
2
  # Resources related to the products in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/products
3
+ # http://docs.veeqo.apiary.io/#reference/products/product-collection/list-all-products
4
4
 
5
5
  module Veeqo
6
6
  class Product < Resource
@@ -1,10 +1,10 @@
1
1
  # PurchaseOrder
2
2
  # Resources related to the purchase order in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/purchase_orders
3
+ # http://docs.veeqo.apiary.io/#reference/purchase-orders/purchase-order-collection/list-all-purchase-orders
4
4
 
5
5
  module Veeqo
6
6
  class PurchaseOrder < Resource
7
- include Veeqo::ResourceActions.new(uri: 'purchase_orders/%d', disable: [:update, :destroy, :destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'purchase_orders/%d', disable: %i[update destroy destroy_all])
8
8
 
9
9
  property :id
10
10
  property :number
@@ -33,7 +33,7 @@ module Veeqo
33
33
 
34
34
  def self.create(params = {})
35
35
  post path.build, params
36
- rescue JSON::ParserError
36
+ rescue Oj::ParseError
37
37
  nil
38
38
  end
39
39
  end
@@ -0,0 +1,21 @@
1
+ # Shipments
2
+ # Resources related to the shipments in the API.
3
+ # http://docs.veeqo.apiary.io/#reference/shipments/shipment-collection/create-a-shipment
4
+
5
+ module Veeqo
6
+ class Shipment < Resource
7
+ include Veeqo::ResourceActions.new(uri: 'shipments/%d', disable: %i[find all count destroy_all])
8
+
9
+ property :allocation_id
10
+ property :carrier
11
+ property :carrier_id
12
+ property :created_at
13
+ property :id
14
+ property :notify_customer
15
+ property :order_id
16
+ property :shipped_by_id
17
+ property :tracking_number
18
+ property :update_remote_order
19
+ property :weight
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # Stock Entries
2
+ # Resources related to the stock entries in the API.
3
+ # http://docs.veeqo.apiary.io/#reference/stock-entries/stock-entry
4
+
5
+ module Veeqo
6
+ class StockEntry < Resource
7
+ include Veeqo::SubresourceActions.new(uri: 'sellables/%d/warehouses/%d/stock_entry', disable: %i[destroy destroy_all all find create])
8
+ property :allocated_stock_level
9
+ property :available_stock_level
10
+ property :id
11
+ property :incoming_stock_level
12
+ property :infinite
13
+ property :location
14
+ property :physical_stock_level
15
+ property :sellable_id
16
+ property :sellable_on_hand_value
17
+ property :stock_running_low
18
+ property :updated_at
19
+ property :warehouse
20
+ property :warehouse_id
21
+ end
22
+ end
@@ -1,10 +1,10 @@
1
- # customers
2
- # Resources related to the customers in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/customers
1
+ # Suppliers
2
+ # Resources related to the suppliers in the API.
3
+ # http://docs.veeqo.apiary.io/#reference/suppliers/supplier-collection
4
4
 
5
5
  module Veeqo
6
6
  class Supplier < Resource
7
- include Veeqo::ResourceActions.new(uri: 'suppliers/%d', disable: [:find, :create, :destroy, :destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'suppliers/%d', disable: %i[find create destroy destroy_all])
8
8
 
9
9
  property :id
10
10
  property :name
@@ -0,0 +1,14 @@
1
+ # Tags
2
+ # Resources related to the tags in the API.
3
+ # http://docs.veeqo.apiary.io/#reference/tags/tag-collection
4
+
5
+ module Veeqo
6
+ class Tag < Resource
7
+ include Veeqo::ResourceActions.new uri: 'tags/%d', disable: %i[destroy_all count]
8
+ property :colour
9
+ property :company_id
10
+ property :id
11
+ property :name
12
+ property :taggings_count
13
+ end
14
+ end
@@ -1,10 +1,10 @@
1
1
  # Warehouses
2
2
  # Resources related to the Warehouses in the API.
3
- # https://developers.veeqo.com/docs/versions/1-0-0-beta/resources/warehouses
3
+ # http://docs.veeqo.apiary.io/#reference/warehouses/warehouse-collection
4
4
 
5
5
  module Veeqo
6
6
  class Warehouse < Resource
7
- include Veeqo::ResourceActions.new(uri: 'warehouses/%d', disable: [:create, :update, :destroy, :destroy_all])
7
+ include Veeqo::ResourceActions.new(uri: 'warehouses/%d', disable: %i[create update destroy destroy_all])
8
8
 
9
9
  property :id
10
10
  property :address_line_1
@@ -1,5 +1,7 @@
1
1
  module Veeqo
2
2
  class SubresourceActions < ResourceActions
3
+ attr_reader :options
4
+
3
5
  def included(base)
4
6
  base.send(:include, Request.new(options[:uri]))
5
7
  base.extend(ClassMethods)
@@ -1,3 +1,3 @@
1
1
  module Veeqo
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veeqo_api_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yurkiv Misha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-04 00:00:00.000000000 Z
11
+ date: 2017-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.9'
75
+ version: 0.13.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.9'
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: oj
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: faraday_middleware
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +152,7 @@ files:
138
152
  - lib/veeqo/middleware/http_exception.rb
139
153
  - lib/veeqo/request.rb
140
154
  - lib/veeqo/resource_actions.rb
155
+ - lib/veeqo/resources/allocation.rb
141
156
  - lib/veeqo/resources/channel.rb
142
157
  - lib/veeqo/resources/company.rb
143
158
  - lib/veeqo/resources/customer.rb
@@ -146,7 +161,10 @@ files:
146
161
  - lib/veeqo/resources/product.rb
147
162
  - lib/veeqo/resources/purchase_order.rb
148
163
  - lib/veeqo/resources/resource.rb
164
+ - lib/veeqo/resources/shipment.rb
165
+ - lib/veeqo/resources/stock_entry.rb
149
166
  - lib/veeqo/resources/supplier.rb
167
+ - lib/veeqo/resources/tag.rb
150
168
  - lib/veeqo/resources/warehouse.rb
151
169
  - lib/veeqo/subresource_actions.rb
152
170
  - lib/veeqo/version.rb