class Sellsy::Clients

Public Class Methods

all() click to toggle source
# File lib/sellsy/clients.rb, line 73
def self.all
  command = {
    'method' => 'Client.getList',
    'params' => {}
  }

  response = MultiJson.load(Sellsy::Api.request command)

  clients = []
  response['response']['result'].each do |key, value|
    client = Client.new
    client.id = key
    client.name = value['fullName']
    clients << client
  end

  return clients
end
find(id) click to toggle source
# File lib/sellsy/clients.rb, line 31
def self.find(id)
  command = {
      'method' => 'Client.getOne',
      'params' => {
          'clientid' => id
      }
  }

  response = MultiJson.load(Sellsy::Api.request command)

  value = response['response']['client']

  client = Client.new
  client.id = value['id']
  client.name = value['name']

  return client
end