Class: ShipitAPI::Sku

Inherits:
Object
  • Object
show all
Defined in:
lib/shipit_api/sku.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Sku

Returns a new instance of Sku.



11
12
13
14
# File 'lib/shipit_api/sku.rb', line 11

def initialize(opts = {})
  @opts = opts
  @api_call = ShipitAPI::Session.connection(self.class.name)
end

Class Method Details

.all(opts = {}) ⇒ Object



7
8
9
# File 'lib/shipit_api/sku.rb', line 7

def self.all(opts = {})
  new(opts).all
end

.find(opts = {}) ⇒ Object



3
4
5
# File 'lib/shipit_api/sku.rb', line 3

def self.find(opts = {})
  new().find(opts)
end

Instance Method Details

#allObject



16
17
18
19
# File 'lib/shipit_api/sku.rb', line 16

def all
  response = @api_call.get('', @opts)
  JSON.parse(response.body, symbolize_names: true)
end

#find(opts = {}) ⇒ Object



21
22
23
24
25
# File 'lib/shipit_api/sku.rb', line 21

def find(opts = {})
  opts = opts.empty? ? StandardError : opts
  response = @api_call.get("#{opts[:id]}")
  JSON.parse(response.body, symbolize_names: true)
end