Class: Synnex::Subscription
- Inherits:
-
Object
- Object
- Synnex::Subscription
- Defined in:
- lib/synnex/synnex_subscription.rb
Instance Attribute Summary collapse
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#msrp ⇒ Object
readonly
Returns the value of attribute msrp.
-
#po ⇒ Object
readonly
Returns the value of attribute po.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#snx_sku_no ⇒ Object
readonly
Returns the value of attribute snx_sku_no.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #cancel(email = nil) ⇒ Object
- #change_quantity(qty, email = nil) ⇒ Object
-
#initialize(json, api) ⇒ Subscription
constructor
A new instance of Subscription.
Constructor Details
#initialize(json, api) ⇒ Subscription
Returns a new instance of Subscription.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/synnex/synnex_subscription.rb', line 4 def initialize(json, api) info = json["subscriptions_info"][0] @id = info["subscription_id"] @service_name = info["service_name"] @snx_sku_no = info["snx_sku_no"] @quantity = info["quantity"] @status = info["status"] @po = json["rs_po_no"] @price = info["unit_price"] @msrp = info["msrp"] @api = api end |
Instance Attribute Details
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def customer @customer end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def id @id end |
#msrp ⇒ Object (readonly)
Returns the value of attribute msrp.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def msrp @msrp end |
#po ⇒ Object (readonly)
Returns the value of attribute po.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def po @po end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def price @price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def quantity @quantity end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def service_name @service_name end |
#snx_sku_no ⇒ Object (readonly)
Returns the value of attribute snx_sku_no.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def snx_sku_no @snx_sku_no end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/synnex/synnex_subscription.rb', line 3 def status @status end |
Instance Method Details
#cancel(email = nil) ⇒ Object
23 24 25 26 |
# File 'lib/synnex/synnex_subscription.rb', line 23 def cancel(email=nil) response = api.cancel_subscription(id, email) response["status"] == "success" ? true : response["message"] end |
#change_quantity(qty, email = nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/synnex/synnex_subscription.rb', line 17 def change_quantity(qty, email=nil) raise "Quantity must be greater than 0" unless qty > 0 response = api.update_seat(id, qty, email) response["status"] == "success" ? true : response["message"] end |