class Shipwire::Products

Public Instance Methods

create(body) click to toggle source
# File lib/shipwire/products.rb, line 7
def create(body)
  request(:post, 'products', body: body_runner(body))
end
delete(id)
Alias for: retire
find(id) click to toggle source
# File lib/shipwire/products.rb, line 11
def find(id)
  request(:get, "products/#{id}")
end
list(params = {}) click to toggle source
# File lib/shipwire/products.rb, line 3
def list(params = {})
  request(:get, 'products', params: params_runner(params))
end
remove(id)
Alias for: retire
retire(id) click to toggle source
# File lib/shipwire/products.rb, line 19
def retire(id)
  request(:post, 'products/retire', body: retire_object(id))
end
Also aliased as: remove, delete
update(id, body) click to toggle source
# File lib/shipwire/products.rb, line 15
def update(id, body)
  request(:put, "products/#{id}", body: body_runner(body))
end

Protected Instance Methods

product_classification() click to toggle source
# File lib/shipwire/products.rb, line 27
def product_classification
  {}
end

Private Instance Methods

body_runner(body) click to toggle source
# File lib/shipwire/products.rb, line 37
def body_runner(body)
  [body].flatten.each_with_object([]) do |item, pl|
    pl << with_product_classification(item)
  end
end
params_runner(params) click to toggle source
# File lib/shipwire/products.rb, line 33
def params_runner(params)
  with_product_classification(params)
end
retire_object(obj) click to toggle source
# File lib/shipwire/products.rb, line 47
def retire_object(obj)
  retire_array = obj.is_a?(Array) ? obj : Utility.split_to_integers(obj)

  { ids: retire_array }
end
with_product_classification(body) click to toggle source
# File lib/shipwire/products.rb, line 43
def with_product_classification(body)
  body.merge(product_classification)
end