class Channable::Client

Public Class Methods

new() click to toggle source
# File lib/channable/client.rb, line 7
def initialize
  self.class.base_uri "https://api.channable.com/v1/companies/#{SpreeChannable.configuration.company_id}/projects/#{SpreeChannable.configuration.project_id}"
  self.class.headers 'Authorization' => "Bearer #{SpreeChannable.configuration.channable_api_key}"
  self.class.headers 'Content-Type' => 'application/json'
end

Public Instance Methods

cancellation_update(order_id) click to toggle source
# File lib/channable/client.rb, line 37
def cancellation_update(order_id)
  Channable::Response.new(self.class.post("/orders/#{order_id}/cancel"))
end
get_orders(start_date: 1.day.ago, offset: 0, limit: 100) click to toggle source
# File lib/channable/client.rb, line 13
def get_orders(start_date: 1.day.ago, offset: 0, limit: 100)
  Channable::Response.new(self.class.get('/orders', query: {
      limit: limit,
      start_date: start_date.strftime('%Y-%m-%d'),
      offset: offset
  }))
end
get_returns(start_date: 1.day.ago, offset: 0, limit: 100) click to toggle source
# File lib/channable/client.rb, line 21
def get_returns(start_date: 1.day.ago, offset: 0, limit: 100)
  Channable::Response.new(self.class.get('/returns', query: {
      limit: limit,
      start_date: start_date,
      offset: offset
  }))
end
return_update(return_id, return_body) click to toggle source
# File lib/channable/client.rb, line 29
def return_update(return_id, return_body)
  Channable::Response.new(self.class.post("/returns/#{return_id}/status", body: return_body))
end
shipment_update(order_id, shipment_body) click to toggle source
# File lib/channable/client.rb, line 33
def shipment_update(order_id, shipment_body)
  Channable::Response.new(self.class.post("/orders/#{order_id}/shipment", body: shipment_body))
end