Class: Pwinty::Client
- Inherits:
-
Object
- Object
- Pwinty::Client
- Defined in:
- lib/pwinty.rb
Instance Method Summary collapse
- #add_photo(**args) ⇒ Object
- #catalog(countryCode: 'US', qualityLevel: 'Standard') ⇒ Object
-
#countries ⇒ Object
Countries.
- #create_order(**args) ⇒ Object
-
#delete_photo(orderId, photoId) ⇒ Object
post :add_photos, “/Orders/:orderId/Photos/Batch”.
-
#get_order_status(id) ⇒ Object
Order Status.
-
#get_orders ⇒ Object
Orders.
- #get_photo(orderId, photoId) ⇒ Object
-
#get_photos(orderId) ⇒ Object
Order Photos.
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #update_order(**args) ⇒ Object
- #update_order_status(id, status) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pwinty.rb', line 13 def initialize subdomain = ENV['PWINTY_PRODUCTION'] == 'true' ? "api" : "sandbox" domain = "https://#{subdomain}.pwinty.com/v2.1" @pwinty = RestClient::Resource.new(domain, :headers => { "X-Pwinty-MerchantId" => ENV['PWINTY_MERCHANT_ID'], "X-Pwinty-REST-API-Key" => ENV['PWINTY_API_KEY'], 'Accept' => 'application/json' }) end |
Instance Method Details
#add_photo(**args) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/pwinty.rb', line 60 def add_photo(**args) headers = {} orderId = args.delete(:orderId) unless args[:file].nil? args, headers = Multipart::Post.prepare_query(args) end JSON.parse @pwinty["/Orders/#{orderId}/Photos"].post(args, headers) end |
#catalog(countryCode: 'US', qualityLevel: 'Standard') ⇒ Object
24 25 26 |
# File 'lib/pwinty.rb', line 24 def catalog(countryCode: 'US', qualityLevel: 'Standard') JSON.parse @pwinty["/Catalogue/#{countryCode}/#{qualityLevel}"].get end |
#countries ⇒ Object
Countries
77 78 79 |
# File 'lib/pwinty.rb', line 77 def countries JSON.parse @pwinty["/Country"].get end |
#create_order(**args) ⇒ Object
33 34 35 |
# File 'lib/pwinty.rb', line 33 def create_order(**args) JSON.parse @pwinty["/Orders"].post(args) end |
#delete_photo(orderId, photoId) ⇒ Object
post :add_photos, “/Orders/:orderId/Photos/Batch”
72 73 74 |
# File 'lib/pwinty.rb', line 72 def delete_photo(orderId, photoId) JSON.parse @pwinty["/Orders/#{orderId}/Photos/#{photoId}"].delete end |
#get_order_status(id) ⇒ Object
Order Status
42 43 44 |
# File 'lib/pwinty.rb', line 42 def get_order_status(id) JSON.parse @pwinty["/Orders/#{id}/SubmissionStatus"].get end |
#get_orders ⇒ Object
Orders
29 30 31 |
# File 'lib/pwinty.rb', line 29 def get_orders JSON.parse @pwinty["/Orders"].get end |
#get_photo(orderId, photoId) ⇒ Object
55 56 57 |
# File 'lib/pwinty.rb', line 55 def get_photo(orderId, photoId) JSON.parse @pwinty["/Orders/#{orderId}/Photos/#{photoId}"].get end |
#get_photos(orderId) ⇒ Object
Order Photos
51 52 53 |
# File 'lib/pwinty.rb', line 51 def get_photos(orderId) JSON.parse @pwinty["/Orders/#{orderId}/Photos"].get end |
#update_order(**args) ⇒ Object
37 38 39 |
# File 'lib/pwinty.rb', line 37 def update_order(**args) JSON.parse @pwinty["/Orders/#{args[:id]}"].put(args) end |
#update_order_status(id, status) ⇒ Object
46 47 48 |
# File 'lib/pwinty.rb', line 46 def update_order_status(id, status) JSON.parse @pwinty["/Orders/#{id}/Status"].post(status: status) end |