Class: Lightspeed::API::Items

Inherits:
Object
  • Object
show all
Includes:
Helpers::Pagination
Defined in:
lib/lightspeed/api/items.rb,
lib/lightspeed/api/items/custom_fields.rb,
lib/lightspeed/api/items/custom_fields/custom_field_choices.rb

Defined Under Namespace

Classes: CustomFields

Instance Method Summary collapse

Methods included from Helpers::Pagination

#with_pages

Constructor Details

#initialize(client) ⇒ Items

Returns a new instance of Items.



10
11
12
# File 'lib/lightspeed/api/items.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#all(limit: nil) ⇒ Object



16
17
18
19
20
# File 'lib/lightspeed/api/items.rb', line 16

def all(limit: nil)
  with_pages(limit: limit) do |options|
    client.get("Account/#{client.}/Item.json?#{options}")
  end
end

#archive(item_id) ⇒ Object



30
31
32
# File 'lib/lightspeed/api/items.rb', line 30

def archive(item_id)
  client.delete("Account/#{client.}/Item/#{item_id}.json").body
end

#create(attributes = {}) ⇒ Object



26
27
28
# File 'lib/lightspeed/api/items.rb', line 26

def create(attributes = {})
  client.post("Account/#{client.}/Item.json", body: attributes).body
end

#custom_fieldsObject



14
# File 'lib/lightspeed/api/items.rb', line 14

def custom_fields; Items::CustomFields.new(client); end

#find(item_id, with: []) ⇒ Object



22
23
24
# File 'lib/lightspeed/api/items.rb', line 22

def find(item_id, with: [])
  client.get("Account/#{client.}/Item/#{item_id}.json", relations: with).body
end

#update(item_id, attributes = {}) ⇒ Object



34
35
36
# File 'lib/lightspeed/api/items.rb', line 34

def update(item_id, attributes = {})
  client.put("Account/#{client.}/Item/#{item_id}.json", body: attributes).body
end