Class: MundiApi::CreateSubscriptionItemRequest
- Defined in:
- lib/mundi_api/models/create_subscription_item_request.rb
Overview
Request for creating a new subscription item
Instance Attribute Summary collapse
-
#cycles ⇒ Integer
Number of cycles which the item will be charged.
-
#description ⇒ String
Item description.
-
#discounts ⇒ List of CreateDiscountRequest
Discounts for the item.
-
#id ⇒ String
Item id.
-
#minimum_price ⇒ Integer
Minimum price.
-
#plan_item_id ⇒ String
Plan item id.
-
#pricing_scheme ⇒ CreatePricingSchemeRequest
Pricing scheme.
-
#quantity ⇒ Integer
Quantity of items.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(description = nil, pricing_scheme = nil, id = nil, plan_item_id = nil, discounts = nil, cycles = nil, quantity = nil, minimum_price = nil) ⇒ CreateSubscriptionItemRequest
constructor
A new instance of CreateSubscriptionItemRequest.
Methods inherited from BaseModel
Constructor Details
#initialize(description = nil, pricing_scheme = nil, id = nil, plan_item_id = nil, discounts = nil, cycles = nil, quantity = nil, minimum_price = nil) ⇒ CreateSubscriptionItemRequest
Returns a new instance of CreateSubscriptionItemRequest.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 55 def initialize(description = nil, pricing_scheme = nil, id = nil, plan_item_id = nil, discounts = nil, cycles = nil, quantity = nil, minimum_price = nil) @description = description @pricing_scheme = pricing_scheme @id = id @plan_item_id = plan_item_id @discounts = discounts @cycles = cycles @quantity = quantity @minimum_price = minimum_price end |
Instance Attribute Details
#cycles ⇒ Integer
Number of cycles which the item will be charged
29 30 31 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 29 def cycles @cycles end |
#description ⇒ String
Item description
9 10 11 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 9 def description @description end |
#discounts ⇒ List of CreateDiscountRequest
Discounts for the item
25 26 27 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 25 def discounts @discounts end |
#id ⇒ String
Item id
17 18 19 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 17 def id @id end |
#minimum_price ⇒ Integer
Minimum price
37 38 39 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 37 def minimum_price @minimum_price end |
#plan_item_id ⇒ String
Plan item id
21 22 23 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 21 def plan_item_id @plan_item_id end |
#pricing_scheme ⇒ CreatePricingSchemeRequest
Pricing scheme
13 14 15 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 13 def pricing_scheme @pricing_scheme end |
#quantity ⇒ Integer
Quantity of items
33 34 35 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 33 def quantity @quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. description = hash['description'] pricing_scheme = CreatePricingSchemeRequest.from_hash(hash['pricing_scheme']) if hash['pricing_scheme'] id = hash['id'] plan_item_id = hash['plan_item_id'] # Parameter is an array, so we need to iterate through it discounts = nil unless hash['discounts'].nil? discounts = [] hash['discounts'].each do |structure| discounts << (CreateDiscountRequest.from_hash(structure) if structure) end end cycles = hash['cycles'] quantity = hash['quantity'] minimum_price = hash['minimum_price'] # Create object from extracted values. CreateSubscriptionItemRequest.new(description, pricing_scheme, id, plan_item_id, discounts, cycles, quantity, minimum_price) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mundi_api/models/create_subscription_item_request.rb', line 40 def self.names if @_hash.nil? @_hash = {} @_hash['description'] = 'description' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['id'] = 'id' @_hash['plan_item_id'] = 'plan_item_id' @_hash['discounts'] = 'discounts' @_hash['cycles'] = 'cycles' @_hash['quantity'] = 'quantity' @_hash['minimum_price'] = 'minimum_price' end @_hash end |