class Customers

Public Class Methods

create(options={}) click to toggle source
# File lib/Customers.rb, line 25
def Customers.create(options={})
  if (options.length == 0)
    raise InvalidArguementError.new()
  end
  method = 'POST'
  url = '/customers'
  response = request(method,url,options)
  customers = Customer.new(response.body)
  return customers
end
delete(options={}) click to toggle source
# File lib/Customers.rb, line 88
def Customers.delete(options={})
  raise "ERROR: Not Implemented"
end
get(options={}) click to toggle source
# File lib/Customers.rb, line 62
def Customers.get(options={})
  customer_id = get_arg(options,:customer_id)
  if customer_id == NIL or customer_id == ''
    raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.get().")
  end

  method = 'GET'
  url = "/customers/#{customer_id}"
  response = request(method,url,options)
  customers = Customer.new(response.body)
  return customers
end
list(options={}) click to toggle source
# File lib/Customers.rb, line 36
def Customers.list(options={})
  method = 'GET'
  url = '/customers'
  offset = get_arg(options,:offset)
  count = get_arg(options,:count)

  if count == NIL and offset == NIL
        puts "count & offset can be passed if required.\n"
  end

  response = request(method,url,options).body
  customer_list = Array(response['list'])
  customers = []
  customer_list.each  do |customerData|
    customer = Customer.new(customerData)
    customers.push(customer)
  end
  customer_response = {
      'count' => response['count'],
      'offset' => response['offset'],
      'total' => response['total'],
      'list' => customers
  }
  return customer_response
end
update(options={}) click to toggle source
# File lib/Customers.rb, line 75
def Customers.update(options={})
  customer_id = get_arg(options,:customer_id)
  if customer_id == NIL or customer_id == ''
    raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.update().")
  end

  method = 'POST'
  url = "/customers/#{customer_id}"
  response = request(method,url,options)
  customers = Customer.new(response.body)
  return customers
end