Sha256: adb4234ff186815ddf16c2d3e757518df207f7a150a1888a310b9adef6c9d66f
Contents?: true
Size: 1.78 KB
Versions: 4
Compression:
Stored size: 1.78 KB
Contents
require 'shipstation/api_operations/list' require 'shipstation/api_operations/create' require 'shipstation/api_resource' require 'shipstation/order' require 'shipstation/customer' require 'shipstation/shipment' require 'shipstation/carrier' require 'shipstation/store' require 'shipstation/warehouse' require 'shipstation/product' module Shipstation API_BASE = "https://ssapi.shipstation.com/" class ShipstationError < StandardError end class AuthenticationError < ShipstationError; end class ConfigurationError < ShipstationError; end class << self def username defined? @username and @username or raise( ConfigurationError, "Shipstation username not configured" ) end attr_writer :username def password defined? @password and @password or raise( ConfigurationError, "Shipstation password not configured" ) end attr_writer :password def request method, resource, params={} defined? method or raise( ArgumentError, "Request method has not been specified" ) defined? resource or raise( ArgumentError, "Request resource has not been specified" ) RestClient::Request.new({ method: method, url: API_BASE + resource, user: Shipstation.username, password: Shipstation.password, payload: params, headers: { :accept => :json, content_type: :json } }).execute do |response, request, result| JSON.parse(response.to_str) end end def datetime_format datetime datetime.strftime("%Y-%m-%d %T") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shipstation-0.2.2 | lib/shipstation.rb |
shipstation-0.2.1 | lib/shipstation.rb |
shipstation-0.1.1 | lib/shipstation.rb |
shipstation-0.1.0 | lib/shipstation.rb |