Class: Customers
- Inherits:
-
Object
- Object
- Customers
- Defined in:
- lib/Customers.rb
Defined Under Namespace
Classes: Customer
Class Method Summary collapse
- .create(options = {}) ⇒ Object
- .delete(options = {}) ⇒ Object
- .get(options = {}) ⇒ Object
- .list(options = {}) ⇒ Object
- .update(options = {}) ⇒ Object
Class Method Details
.create(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/Customers.rb', line 25 def Customers.create(={}) if (.length == 0) raise InvalidArguementError.new() end method = 'POST' url = '/customers' response = request(method,url,) customers = Customer.new(response.body) return customers end |
.delete(options = {}) ⇒ Object
88 89 90 |
# File 'lib/Customers.rb', line 88 def Customers.delete(={}) raise "ERROR: Not Implemented" end |
.get(options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/Customers.rb', line 62 def Customers.get(={}) customer_id = get_arg(,:customer_id) if customer_id == NIL raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.get().") end method = 'GET' url = "/customers/#{customer_id}" response = request(method,url,) customers = Customer.new(response.body) return customers end |
.list(options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/Customers.rb', line 36 def Customers.list(={}) method = 'GET' url = '/customers' offset = get_arg(,:offset) count = get_arg(,:count) if count == NIL and offset == NIL puts "count & offset can be passed if required.\n" end response = request(method,url,).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 = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/Customers.rb', line 75 def Customers.update(={}) customer_id = get_arg(,:customer_id) if customer_id == NIL raise InvalidArguementError.new("ERROR: `customer_id` is a required parameter for Customers.update().") end method = 'POST' url = "/customers/#{customer_id}" response = request(method,url,) customers = Customer.new(response.body) return customers end |