bigcommerce_api 0.5.4 → 0.6.2
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 +4 -4
- data/lib/bigcommerce_api/base.rb +15 -8
- data/lib/bigcommerce_api/image.rb +1 -1
- data/lib/bigcommerce_api/inflections.rb +8 -0
- data/lib/bigcommerce_api/modules/countable.rb +14 -0
- data/lib/bigcommerce_api/order.rb +2 -0
- data/lib/bigcommerce_api/order_product.rb +4 -0
- data/lib/bigcommerce_api/product.rb +3 -1
- data/lib/bigcommerce_api/resource.rb +37 -12
- data/lib/bigcommerce_api/result.rb +13 -0
- data/lib/bigcommerce_api/shipment.rb +4 -0
- data/lib/bigcommerce_api/shippingaddress.rb +4 -0
- data/lib/bigcommerce_api/sku.rb +5 -0
- data/lib/bigcommerce_api/tax_class.rb +10 -0
- data/lib/bigcommerce_api.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34769ffea0359f1f9a04ea1d72a88ea3e71b3aa2
|
4
|
+
data.tar.gz: 35465d8fd5ac884171670fff9376b7229131f3e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc64c1c91bd8f9fe5c59775f00ddf897ac2fb21ed480a99592e6a4f86f187e2f8d62512ffc977291488833d21318b4791beea4d62191414e23c543510eefb464
|
7
|
+
data.tar.gz: 231af73c8d64a31050d32f981022f0a14257f4e4e887b9d38865e2dc4e2b0d5e6530ca6e3d85c1fa68739ab392a70f67f91000eb77af7d144fda506450a938c6
|
data/lib/bigcommerce_api/base.rb
CHANGED
@@ -28,17 +28,24 @@ module BigcommerceAPI
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def time
|
31
|
-
|
32
|
-
|
31
|
+
begin
|
32
|
+
response = self.class.get('/time')
|
33
|
+
response.parsed_response['time']
|
34
|
+
rescue SocketError => each
|
35
|
+
false
|
36
|
+
end
|
33
37
|
end
|
34
|
-
alias_method :get_time, :time
|
35
38
|
|
36
39
|
def store
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
begin
|
41
|
+
response = self.class.get('/store')
|
42
|
+
if response
|
43
|
+
return Store.new(response.parsed_response)
|
44
|
+
else
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
rescue SocketError => each
|
48
|
+
false
|
42
49
|
end
|
43
50
|
end
|
44
51
|
alias_method :info, :store
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module BigcommerceAPI
|
2
2
|
|
3
3
|
class Image < Resource
|
4
|
-
attr_accessor :id, :image_file, :product_id, :sort_order, :is_thumbnail, :description, :date_created
|
4
|
+
attr_accessor :id, :image_file, :product_id, :sort_order, :is_thumbnail, :description, :date_created, :zoom_url, :thumbnail_url, :standard_url, :tiny_url
|
5
5
|
|
6
6
|
belongs_to :product
|
7
7
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module BigcommerceAPI
|
2
|
+
|
3
|
+
module Countable
|
4
|
+
|
5
|
+
def count(params = {})
|
6
|
+
|
7
|
+
response = BigcommerceAPI::Resource.http_request(:get, "/#{resource}/count", :query => date_adjust(params))
|
8
|
+
(response.success? and !response.nil?) ? response['count'] : nil
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module BigcommerceAPI
|
2
2
|
|
3
3
|
class Order < Resource
|
4
|
+
extend BigcommerceAPI::Countable
|
5
|
+
|
4
6
|
attr_accessor :refunded_amount, :payment_status, :handling_cost_inc_tax, :shipping_cost_ex_tax, :handling_cost_tax, :currency_id, :items_shipped, :handling_cost_ex_tax, :discount_amount, :staff_notes, :default_currency_id, :store_credit_amount, :payment_method, :total_ex_tax, :subtotal_inc_tax, :subtotal_ex_tax, :date_modified, :currency_exchange_rate, :wrapping_cost_inc_tax, :wrapping_cost_ex_tax, :handling_cost_tax_class_id, :base_handling_cost, :id, :is_deleted, :coupon_discount, :customer_message, :geoip_country, :gift_certificate_amount, :total_inc_tax, :base_wrapping_cost, :date_shipped, :billing_address, :geoip_country_iso2, :payment_provider_id, :wrapping_cost_tax_class_id, :base_shipping_cost, :subtotal_tax, :wrapping_cost_tax, :status_id, :customer_id, :default_currency_code, :currency_code, :order_is_digital, :items_total, :total_tax, :shipping_cost_inc_tax, :status, :shipping_address_count, :ip_address, :shipping_cost_tax_class_id, :shipping_cost_tax, :date_created, :products_hash, :shipping_addresses_hash, :coupons_hash
|
5
7
|
# :coupons, :shipping_addresses,
|
6
8
|
|
@@ -32,6 +32,10 @@ module BigcommerceAPI
|
|
32
32
|
'order'
|
33
33
|
end
|
34
34
|
|
35
|
+
def find_for_reload
|
36
|
+
self.class.find(self.order_id, self.id)
|
37
|
+
end
|
38
|
+
|
35
39
|
class << self
|
36
40
|
def all(order_id, params={})
|
37
41
|
resources = BigcommerceAPI::Base.get("/orders/#{order_id}/products", :query => date_adjust(params))
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module BigcommerceAPI
|
2
2
|
|
3
3
|
class Product < Resource
|
4
|
+
extend BigcommerceAPI::Countable
|
5
|
+
|
4
6
|
# incoming attributes
|
5
|
-
attr_accessor :brand_id, :myob_expense_account, :inventory_tracking, :preorder_release_date, :tax_class_id, :sku, :date_modified, :fixed_cost_shipping_price, :categories, :meta_description, :sort_order, :related_products, :
|
7
|
+
attr_accessor :brand_id, :myob_expense_account, :inventory_tracking, :preorder_release_date, :tax_class_id, :sku, :date_modified, :fixed_cost_shipping_price, :categories, :meta_description, :sort_order, :related_products, :is_visible, :description, :layout_file, :meta_keywords, :rating_total, :price, :event_date_field_name, :height, :order_quantity_minimum, :myob_asset_account, :order_quantity_maximum, :peachtree_gl_account, :retail_price, :availability_description, :weight, :is_preorder_only, :date_created, :open_graph_title, :rating_count, :open_graph_type, :option_set_id, :is_featured, :date_last_imported, :option_set_display, :availability, :is_condition_shown, :name, :inventory_warning_level, :event_date_end, :cost_price, :inventory_level, :event_date_type, :upc, :open_graph_description, :depth, :custom_url, :myob_income_account, :condition, :is_price_hidden, :custom_fields, :configurable_fields, :discount_rules, :warranty, :total_sold, :view_count, :event_date_start, :price_hidden_label, :videos, :sale_price, :bin_picking_number, :preorder_message, :is_open_graph_thumbnail, :search_keywords, :is_free_shipping, :width, :type, :id, :page_title, :downloads
|
6
8
|
# has_many
|
7
9
|
attr_accessor :options_hash, :skus_hash, :rules_hash, :images_hash
|
8
10
|
|
@@ -18,19 +18,24 @@ module BigcommerceAPI
|
|
18
18
|
self.attributes_were = data
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
def mark_dirty!
|
22
|
+
self.attributes_were = {}
|
23
|
+
self
|
24
|
+
end
|
25
25
|
|
26
|
+
def save
|
27
|
+
url = self.resource_url
|
26
28
|
if self.id.nil?
|
27
|
-
|
29
|
+
# delete the parent id if there is one
|
30
|
+
self.send(self.parent + '_id=', nil) if !self.parent.nil?
|
31
|
+
|
32
|
+
response = BigcommerceAPI::Resource.http_request(:post, "/#{url}", :body => self.attributes(true).to_json)
|
28
33
|
else
|
29
34
|
# only send updated attributes
|
30
35
|
attrs = self.attributes
|
31
36
|
body = Hash.new
|
32
37
|
self.changed.each{|c| body[c] = attrs[c]}
|
33
|
-
response = BigcommerceAPI::
|
38
|
+
response = BigcommerceAPI::Resource.http_request(:put, "/#{url}/#{self.id}", :body => body.to_json)
|
34
39
|
end
|
35
40
|
if response.success?
|
36
41
|
return self.id.nil? ? self.class.new(response.parsed_response) : true
|
@@ -45,7 +50,7 @@ module BigcommerceAPI
|
|
45
50
|
url = self.resource_url
|
46
51
|
self.send(self.parent + '_id=', nil) if !self.parent.nil?
|
47
52
|
|
48
|
-
response = BigcommerceAPI::
|
53
|
+
response = BigcommerceAPI::Resource.http_request(:post, "/#{url}", :body => date_adjust(params).to_json)
|
49
54
|
if response.success?
|
50
55
|
return self.class.new(response.parsed_response)
|
51
56
|
else
|
@@ -54,6 +59,18 @@ module BigcommerceAPI
|
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
62
|
+
def find_for_reload
|
63
|
+
self.class.find(self.id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def reload
|
67
|
+
updated = self.find_for_reload
|
68
|
+
self.attributes.each do |k, v|
|
69
|
+
self.send("#{k}=", updated.send(k))
|
70
|
+
end
|
71
|
+
return self
|
72
|
+
end
|
73
|
+
|
57
74
|
def resource
|
58
75
|
self.class.name.downcase.to_s.split('::').last
|
59
76
|
end
|
@@ -89,7 +106,7 @@ module BigcommerceAPI
|
|
89
106
|
res = m.to_s
|
90
107
|
end
|
91
108
|
define_method meth do
|
92
|
-
out = BigcommerceAPI::
|
109
|
+
out = BigcommerceAPI::Resource.http_request(:get, "#{self.send(meth + '_hash')['resource']}")
|
93
110
|
obj = res.singularize.camelize
|
94
111
|
if out and !defined?('BigcommerceAPI::' + obj).nil?
|
95
112
|
(out.success? and !out.nil?) ? out.collect{|o| ('BigcommerceAPI::' + obj).constantize.new(o)} : []
|
@@ -109,7 +126,7 @@ module BigcommerceAPI
|
|
109
126
|
resource = m.to_s
|
110
127
|
end
|
111
128
|
define_method meth do
|
112
|
-
out = BigcommerceAPI::
|
129
|
+
out = BigcommerceAPI::Resource.http_request(:get, "#{self.send(meth + '_resource')['resource']}")
|
113
130
|
obj = resource.singularize.camelize
|
114
131
|
if out and !defined?('BigcommerceAPI::' + obj).nil?
|
115
132
|
(out.success? and !out.nil?) ? ('BigcommerceAPI::' + obj).constantize.new(out) : nil
|
@@ -131,7 +148,7 @@ module BigcommerceAPI
|
|
131
148
|
define_method meth do
|
132
149
|
obj = resource.singularize.camelize
|
133
150
|
url = '/' + meth.pluralize + '/' + self.send(meth + "_id").to_s
|
134
|
-
out = BigcommerceAPI::
|
151
|
+
out = BigcommerceAPI::Resource.http_request(:get, "#{url}")
|
135
152
|
if out and !defined?('BigcommerceAPI::' + obj).nil?
|
136
153
|
(out.success? and !out.nil?) ? ('BigcommerceAPI::' + obj).constantize.new(out) : nil
|
137
154
|
end
|
@@ -153,14 +170,22 @@ module BigcommerceAPI
|
|
153
170
|
end
|
154
171
|
|
155
172
|
def all(params={})
|
156
|
-
resources = BigcommerceAPI::
|
173
|
+
resources = BigcommerceAPI::Resource.http_request(:get, "/#{resource}", :query => date_adjust(params))
|
157
174
|
(resources.success? and !resources.nil?) ? resources.collect{|r| self.new(r)} : []
|
158
175
|
end
|
159
176
|
|
160
177
|
def find(id)
|
161
|
-
|
178
|
+
r = BigcommerceAPI::Resource.http_request(:get, "/#{resource}/#{id}")
|
162
179
|
(r.success? and !r.nil?) ? self.new(r) : nil
|
163
180
|
end
|
181
|
+
|
182
|
+
def http_request(verb, url, options={})
|
183
|
+
begin
|
184
|
+
BigcommerceAPI::Base.send(verb, url, options)
|
185
|
+
rescue SocketError => e
|
186
|
+
BigcommerceAPI::Result.new(:success => false, :errors => "Invalid URL")
|
187
|
+
end
|
188
|
+
end
|
164
189
|
end # end class methods
|
165
190
|
|
166
191
|
private
|
@@ -14,6 +14,10 @@ module BigcommerceAPI
|
|
14
14
|
'order'
|
15
15
|
end
|
16
16
|
|
17
|
+
def find_for_reload
|
18
|
+
self.class.find(self.order_id, self.id)
|
19
|
+
end
|
20
|
+
|
17
21
|
class << self
|
18
22
|
def all(order_id, params={})
|
19
23
|
resources = BigcommerceAPI::Base.get("/orders/#{order_id}/shipments", :query => date_adjust(params))
|
@@ -25,6 +25,10 @@ module BigcommerceAPI
|
|
25
25
|
return false
|
26
26
|
end
|
27
27
|
|
28
|
+
def find_for_reload
|
29
|
+
self.class.find(self.order_id, self.id)
|
30
|
+
end
|
31
|
+
|
28
32
|
class << self
|
29
33
|
def all(order_id, params={})
|
30
34
|
resources = BigcommerceAPI::Base.get("/orders/#{order_id}/shippingaddresses", :query => date_adjust(params))
|
data/lib/bigcommerce_api/sku.rb
CHANGED
@@ -41,6 +41,11 @@ module BigcommerceAPI
|
|
41
41
|
return out.join(' ')
|
42
42
|
end
|
43
43
|
|
44
|
+
# we override this on resources that need paired IDs for find
|
45
|
+
def find_for_reload
|
46
|
+
self.class.find(self.product_id, self.id)
|
47
|
+
end
|
48
|
+
|
44
49
|
class << self
|
45
50
|
def all(product_id, params={})
|
46
51
|
resources = BigcommerceAPI::Base.get("/products/#{product_id}/skus", :query => date_adjust(params))
|
data/lib/bigcommerce_api.rb
CHANGED
@@ -2,8 +2,13 @@ require "rubygems"
|
|
2
2
|
require 'httparty'
|
3
3
|
require 'active_support/inflector'
|
4
4
|
|
5
|
+
# Base files & config
|
6
|
+
require 'bigcommerce_api/inflections'
|
7
|
+
require 'bigcommerce_api/modules/countable'
|
5
8
|
require 'bigcommerce_api/base'
|
6
9
|
require 'bigcommerce_api/resource'
|
10
|
+
|
11
|
+
# Resources
|
7
12
|
require 'bigcommerce_api/category'
|
8
13
|
require 'bigcommerce_api/brand'
|
9
14
|
require 'bigcommerce_api/image'
|
@@ -16,6 +21,7 @@ require 'bigcommerce_api/order_product'
|
|
16
21
|
require 'bigcommerce_api/order_status'
|
17
22
|
require 'bigcommerce_api/product'
|
18
23
|
require 'bigcommerce_api/product_option'
|
24
|
+
require 'bigcommerce_api/result'
|
19
25
|
require 'bigcommerce_api/rule'
|
20
26
|
require 'bigcommerce_api/shipment'
|
21
27
|
require 'bigcommerce_api/shippingaddress'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigcommerce_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Dickson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -93,6 +93,8 @@ files:
|
|
93
93
|
- lib/bigcommerce_api/brand.rb
|
94
94
|
- lib/bigcommerce_api/category.rb
|
95
95
|
- lib/bigcommerce_api/image.rb
|
96
|
+
- lib/bigcommerce_api/inflections.rb
|
97
|
+
- lib/bigcommerce_api/modules/countable.rb
|
96
98
|
- lib/bigcommerce_api/option.rb
|
97
99
|
- lib/bigcommerce_api/option_set.rb
|
98
100
|
- lib/bigcommerce_api/option_set_option.rb
|
@@ -103,11 +105,13 @@ files:
|
|
103
105
|
- lib/bigcommerce_api/product.rb
|
104
106
|
- lib/bigcommerce_api/product_option.rb
|
105
107
|
- lib/bigcommerce_api/resource.rb
|
108
|
+
- lib/bigcommerce_api/result.rb
|
106
109
|
- lib/bigcommerce_api/rule.rb
|
107
110
|
- lib/bigcommerce_api/shipment.rb
|
108
111
|
- lib/bigcommerce_api/shippingaddress.rb
|
109
112
|
- lib/bigcommerce_api/sku.rb
|
110
113
|
- lib/bigcommerce_api/store.rb
|
114
|
+
- lib/bigcommerce_api/tax_class.rb
|
111
115
|
- LICENSE.txt
|
112
116
|
- README.md
|
113
117
|
homepage: http://github.com/ideaoforder/bigcommerce_api
|