Class: ActiveMerchant::Fulfillment::ShopifyAPIService
- Inherits:
-
Service
- Object
- Service
- ActiveMerchant::Fulfillment::ShopifyAPIService
show all
- Defined in:
- lib/active_fulfillment/fulfillment/services/shopify_api.rb
Constant Summary
collapse
- RESCUABLE_CONNECTION_ERRORS =
[
Net::ReadTimeout,
Net::OpenTimeout,
TimeoutError,
Errno::ETIMEDOUT,
Timeout::Error,
IOError,
EOFError,
SocketError,
Errno::ECONNRESET,
Errno::ECONNABORTED,
Errno::EPIPE,
Errno::ECONNREFUSED,
Errno::EAGAIN,
Errno::EHOSTUNREACH,
Errno::ENETUNREACH,
Resolv::ResolvError,
Net::HTTPBadResponse,
Net::HTTPHeaderSyntaxError,
Net::ProtocolError,
ActiveMerchant::ConnectionError,
ActiveMerchant::ResponseError,
ActiveMerchant::InvalidResponseError
]
Instance Method Summary
collapse
Methods inherited from Service
#fetch_tracking_numbers, #test?, #test_mode?, #valid_credentials?
Constructor Details
Returns a new instance of ShopifyAPIService.
30
31
32
33
34
|
# File 'lib/active_fulfillment/fulfillment/services/shopify_api.rb', line 30
def initialize(options = {})
@name = options[:name]
@callback_url = options[:callback_url]
@format = options[:format]
end
|
Instance Method Details
#fetch_stock_levels(options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/active_fulfillment/fulfillment/services/shopify_api.rb', line 40
def fetch_stock_levels(options = {})
response = send_app_request('fetch_stock', options.delete(:headers), options)
if response
stock_levels = parse_response(response, 'StockLevels', 'Product', 'Sku', 'Quantity') { |p| p.to_i }
Response.new(true, "API stock levels", {:stock_levels => stock_levels})
else
Response.new(false, "Unable to fetch remote stock levels")
end
end
|
#fetch_tracking_data(order_ids, options = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/active_fulfillment/fulfillment/services/shopify_api.rb', line 50
def fetch_tracking_data(order_ids, options = {})
options.merge!({:order_ids => order_ids})
response = send_app_request('fetch_tracking_numbers', options.delete(:headers), options)
if response
tracking_numbers = parse_response(response, 'TrackingNumbers', 'Order', 'ID', 'Tracking') { |o| o }
Response.new(true, "API tracking_numbers", {:tracking_numbers => tracking_numbers,
:tracking_companies => {},
:tracking_urls => {}})
else
Response.new(false, "Unable to fetch remote tracking numbers #{order_ids.inspect}")
end
end
|
#fulfill(order_id, shipping_address, line_items, options = {}) ⇒ Object
36
37
38
|
# File 'lib/active_fulfillment/fulfillment/services/shopify_api.rb', line 36
def fulfill(order_id, shipping_address, line_items, options = {})
raise NotImplementedError.new("Shopify API Service must listen to fulfillment/create Webhooks")
end
|