Class: Synnex::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/synnex/synnex_subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#customerObject (readonly)

Returns the value of attribute customer.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def customer
  @customer
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def id
  @id
end

#msrpObject (readonly)

Returns the value of attribute msrp.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def msrp
  @msrp
end

#poObject (readonly)

Returns the value of attribute po.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def po
  @po
end

#priceObject (readonly)

Returns the value of attribute price.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



3
4
5
# File 'lib/synnex/synnex_subscription.rb', line 3

def quantity
  @quantity
end

#service_nameObject (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_noObject (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

#statusObject (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