Class: Synnex::Customer
- Inherits:
-
Object
- Object
- Synnex::Customer
- Defined in:
- lib/synnex/synnex_customer.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
readonly
Returns the value of attribute address1.
-
#address2 ⇒ Object
readonly
Returns the value of attribute address2.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#company_name ⇒ Object
readonly
Returns the value of attribute company_name.
-
#contact_name ⇒ Object
readonly
Returns the value of attribute contact_name.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#snx_eu_no ⇒ Object
readonly
Returns the value of attribute snx_eu_no.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#zip_code ⇒ Object
readonly
Returns the value of attribute zip_code.
Instance Method Summary collapse
- #api ⇒ Object
-
#create_order(line_items, rs_po = nil, eu_po = nil, email = nil) ⇒ Object
line_items is an array (optional) of the following hash 12345, quantity: 1 returns true for success.
-
#initialize(json, msp) ⇒ Customer
constructor
A new instance of Customer.
- #licenses ⇒ Object
- #subscriptions ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(json, msp) ⇒ Customer
Returns a new instance of Customer.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/synnex/synnex_customer.rb', line 4 def initialize(json, msp) @snx_eu_no = json["snx_eu_no"] @company_name = json["company_name"] @address1 = json["address1"] @address2 = json["address2"] @city = json["city"] @state = json["state"] @zip_code = json["zip_code"] @country = json["country"] @contact_name = json["contact_name"] @email = json["email"] @phone = json["phone"] @tenant_id = json["tenant_id"] @api = msp.api end |
Instance Attribute Details
#address1 ⇒ Object (readonly)
Returns the value of attribute address1.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def address1 @address1 end |
#address2 ⇒ Object (readonly)
Returns the value of attribute address2.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def address2 @address2 end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def city @city end |
#company_name ⇒ Object (readonly)
Returns the value of attribute company_name.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def company_name @company_name end |
#contact_name ⇒ Object (readonly)
Returns the value of attribute contact_name.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def contact_name @contact_name end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def country @country end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def email @email end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def phone @phone end |
#snx_eu_no ⇒ Object (readonly)
Returns the value of attribute snx_eu_no.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def snx_eu_no @snx_eu_no end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def state @state end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def tenant_id @tenant_id end |
#zip_code ⇒ Object (readonly)
Returns the value of attribute zip_code.
3 4 5 |
# File 'lib/synnex/synnex_customer.rb', line 3 def zip_code @zip_code end |
Instance Method Details
#api ⇒ Object
49 50 51 |
# File 'lib/synnex/synnex_customer.rb', line 49 def api @api end |
#create_order(line_items, rs_po = nil, eu_po = nil, email = nil) ⇒ Object
line_items is an array (optional) of the following hash 12345, quantity: 1 returns true for success
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/synnex/synnex_customer.rb', line 35 def create_order(line_items, rs_po=nil , eu_po=nil , email=nil) case line_items when Hash raise "line_items must follow {snx_sku_no: 12345, quantity: 1} convention" unless (line_items[:snx_sku_no].to_i > 0 && line_items[:quantity].to_i > 0) line_items = [line_items] when Array raise "line_items must follow [{snx_sku_no: 12345, quantity: 1}, ...] convention" unless (line_items[0][:snx_sku_no].to_i > 0 && line_items[0][:quantity].to_i > 0) else raise "line_items must be a hash or array of hashes" end response = api.create_new_order(snx_eu_no, line_items, rs_po, eu_po, email) response["status"] == "success" ? true : response["message"] end |
#licenses ⇒ Object
25 26 27 |
# File 'lib/synnex/synnex_customer.rb', line 25 def licenses api.get_licenses(tenant_access_token, @snx_eu_no) end |
#subscriptions ⇒ Object
20 21 22 23 |
# File 'lib/synnex/synnex_customer.rb', line 20 def subscriptions @subscriptions ||= api.customer_subscription(@snx_eu_no) .map {|subscription| Synnex::Subscription.new(api.subscription(subscription["subscription_id"]), self.api)} end |
#users ⇒ Object
29 30 31 |
# File 'lib/synnex/synnex_customer.rb', line 29 def users @users ||= api.customer_users(@snx_eu_no) end |