Module: Shipstation
- Defined in:
- lib/shipstation.rb,
lib/shipstation/tag.rb,
lib/shipstation/order.rb,
lib/shipstation/store.rb,
lib/shipstation/carrier.rb,
lib/shipstation/product.rb,
lib/shipstation/version.rb,
lib/shipstation/webhook.rb,
lib/shipstation/customer.rb,
lib/shipstation/shipment.rb,
lib/shipstation/warehouse.rb,
lib/shipstation/api_resource.rb,
lib/shipstation/api_operations/list.rb,
lib/shipstation/api_operations/create.rb,
lib/shipstation/api_operations/delete.rb,
lib/shipstation/api_operations/update.rb,
lib/shipstation/api_operations/retrieve.rb,
lib/shipstation/api_operations/shipment.rb
Defined Under Namespace
Modules: APIOperations
Classes: ApiRequestError, ApiResource, AuthenticationError, Carrier, ConfigurationError, Customer, Order, Product, Shipment, ShipstationError, Store, Tag, Warehouse, Webhook
Constant Summary
collapse
- API_BASE =
"https://ssapi.shipstation.com/"
- VERSION =
"0.23"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.password ⇒ Object
52
53
54
55
56
|
# File 'lib/shipstation.rb', line 52
def password
defined? @password and @password or raise(
ConfigurationError, "Shipstation password not configured"
)
end
|
.username ⇒ Object
44
45
46
47
48
|
# File 'lib/shipstation.rb', line 44
def username
defined? @username and @username or raise(
ConfigurationError, "Shipstation username not configured"
)
end
|
Class Method Details
92
93
94
|
# File 'lib/shipstation.rb', line 92
def datetime_format datetime
datetime.strftime("%Y-%m-%d %T")
end
|
.request(method, resource, params = {}) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/shipstation.rb', line 60
def request method, resource, params = {}
ss_username = params[:username] || Shipstation.username
ss_password = params[:password] || Shipstation.password
params.except!(:username, :password)
defined? method or raise(
ArgumentError, "Request method has not been specified"
)
defined? resource or raise(
ArgumentError, "Request resource has not been specified"
)
if method == :get
= {:accept => :json, content_type: :json}.merge({params: params})
payload = nil
else
= {:accept => :json, content_type: :json}
payload = params
end
RestClient::Request.new({
method: method,
url: API_BASE + resource,
user: ss_username,
password: ss_password,
payload: payload ? payload.to_json : nil,
headers:
}).execute do |response, request, result|
str_response = response.to_str
str_response.blank? ? '' : JSON.parse(str_response)
end
end
|