Class: PaypalServerSdk::BillingPlan

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/billing_plan.rb

Overview

The plan details.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, product_id: SKIP, name: SKIP, status: SKIP, description: SKIP, billing_cycles: SKIP, payment_preferences: SKIP, merchant_preferences: SKIP, taxes: SKIP, quantity_supported: false, create_time: SKIP, update_time: SKIP, links: SKIP) ⇒ BillingPlan

Returns a new instance of BillingPlan.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 116

def initialize(id: SKIP, product_id: SKIP, name: SKIP, status: SKIP,
               description: SKIP, billing_cycles: SKIP,
               payment_preferences: SKIP, merchant_preferences: SKIP,
               taxes: SKIP, quantity_supported: false, create_time: SKIP,
               update_time: SKIP, links: SKIP)
  @id = id unless id == SKIP
  @product_id = product_id unless product_id == SKIP
  @name = name unless name == SKIP
  @status = status unless status == SKIP
  @description = description unless description == SKIP
  @billing_cycles = billing_cycles unless billing_cycles == SKIP
  @payment_preferences = payment_preferences unless payment_preferences == SKIP
  @merchant_preferences = merchant_preferences unless merchant_preferences == SKIP
  @taxes = taxes unless taxes == SKIP
  @quantity_supported = quantity_supported unless quantity_supported == SKIP
  @create_time = create_time unless create_time == SKIP
  @update_time = update_time unless update_time == SKIP
  @links = links unless links == SKIP
end

Instance Attribute Details

#billing_cyclesArray[SubscriptionBillingCycle]

An array of billing cycles for trial billing and regular billing. A plan can have at most two trial cycles and only one regular cycle.

Returns:



35
36
37
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 35

def billing_cycles
  @billing_cycles
end

#create_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


59
60
61
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 59

def create_time
  @create_time
end

#descriptionString

The detailed description of the plan.

Returns:

  • (String)


30
31
32
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 30

def description
  @description
end

#idString

The unique PayPal-generated ID for the plan.

Returns:

  • (String)


14
15
16
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 14

def id
  @id
end

An array of request-related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links).

Returns:



71
72
73
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 71

def links
  @links
end

#merchant_preferencesMerchantPreferences

The merchant preferences for a subscription.

Returns:



43
44
45
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 43

def merchant_preferences
  @merchant_preferences
end

#nameString

The plan name.

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 22

def name
  @name
end

#payment_preferencesPaymentPreferences

The payment preferences for a subscription.

Returns:



39
40
41
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 39

def payment_preferences
  @payment_preferences
end

#product_idString

The ID for the product.

Returns:

  • (String)


18
19
20
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 18

def product_id
  @product_id
end

#quantity_supportedTrueClass | FalseClass

Indicates whether you can subscribe to this plan by providing a quantity for the goods or service.

Returns:

  • (TrueClass | FalseClass)


52
53
54
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 52

def quantity_supported
  @quantity_supported
end

#statusSubscriptionPlanStatus

The plan status.



26
27
28
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 26

def status
  @status
end

#taxesTaxes

The tax details.

Returns:



47
48
49
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 47

def taxes
  @taxes
end

#update_timeString

The date and time, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional. Note: The regular expression provides guidance but does not reject all invalid dates.

Returns:

  • (String)


66
67
68
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 66

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 137

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  # Parameter is an array, so we need to iterate through it
  billing_cycles = nil
  unless hash['billing_cycles'].nil?
    billing_cycles = []
    hash['billing_cycles'].each do |structure|
      billing_cycles << (SubscriptionBillingCycle.from_hash(structure) if structure)
    end
  end

  billing_cycles = SKIP unless hash.key?('billing_cycles')
  payment_preferences = PaymentPreferences.from_hash(hash['payment_preferences']) if
    hash['payment_preferences']
  merchant_preferences = MerchantPreferences.from_hash(hash['merchant_preferences']) if
    hash['merchant_preferences']
  taxes = Taxes.from_hash(hash['taxes']) if hash['taxes']
  quantity_supported = hash['quantity_supported'] ||= false
  create_time = hash.key?('create_time') ? hash['create_time'] : SKIP
  update_time = hash.key?('update_time') ? hash['update_time'] : SKIP
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (LinkDescription.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')

  # Create object from extracted values.
  BillingPlan.new(id: id,
                  product_id: product_id,
                  name: name,
                  status: status,
                  description: description,
                  billing_cycles: billing_cycles,
                  payment_preferences: payment_preferences,
                  merchant_preferences: merchant_preferences,
                  taxes: taxes,
                  quantity_supported: quantity_supported,
                  create_time: create_time,
                  update_time: update_time,
                  links: links)
end

.namesObject

A mapping from model property names to API property names.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 74

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['product_id'] = 'product_id'
  @_hash['name'] = 'name'
  @_hash['status'] = 'status'
  @_hash['description'] = 'description'
  @_hash['billing_cycles'] = 'billing_cycles'
  @_hash['payment_preferences'] = 'payment_preferences'
  @_hash['merchant_preferences'] = 'merchant_preferences'
  @_hash['taxes'] = 'taxes'
  @_hash['quantity_supported'] = 'quantity_supported'
  @_hash['create_time'] = 'create_time'
  @_hash['update_time'] = 'update_time'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



112
113
114
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 112

def self.nullables
  []
end

.optionalsObject

An array for optional fields



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 93

def self.optionals
  %w[
    id
    product_id
    name
    status
    description
    billing_cycles
    payment_preferences
    merchant_preferences
    taxes
    quantity_supported
    create_time
    update_time
    links
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



202
203
204
205
206
207
208
209
210
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 202

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, product_id: #{@product_id.inspect}, name:"\
  " #{@name.inspect}, status: #{@status.inspect}, description: #{@description.inspect},"\
  " billing_cycles: #{@billing_cycles.inspect}, payment_preferences:"\
  " #{@payment_preferences.inspect}, merchant_preferences: #{@merchant_preferences.inspect},"\
  " taxes: #{@taxes.inspect}, quantity_supported: #{@quantity_supported.inspect}, create_time:"\
  " #{@create_time.inspect}, update_time: #{@update_time.inspect}, links: #{@links.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



192
193
194
195
196
197
198
199
# File 'lib/paypal_server_sdk/models/billing_plan.rb', line 192

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, product_id: #{@product_id}, name: #{@name}, status: #{@status},"\
  " description: #{@description}, billing_cycles: #{@billing_cycles}, payment_preferences:"\
  " #{@payment_preferences}, merchant_preferences: #{@merchant_preferences}, taxes: #{@taxes},"\
  " quantity_supported: #{@quantity_supported}, create_time: #{@create_time}, update_time:"\
  " #{@update_time}, links: #{@links}>"
end