Class: PaypalServerSdk::Subscription

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

Overview

The subscription 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, plan_id: SKIP, start_time: SKIP, quantity: SKIP, shipping_amount: SKIP, subscriber: SKIP, billing_info: SKIP, create_time: SKIP, update_time: SKIP, custom_id: SKIP, plan_overridden: SKIP, plan: SKIP, links: SKIP) ⇒ Subscription

Returns a new instance of Subscription.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/paypal_server_sdk/models/subscription.rb', line 119

def initialize(id: SKIP, plan_id: SKIP, start_time: SKIP, quantity: SKIP,
               shipping_amount: SKIP, subscriber: SKIP, billing_info: SKIP,
               create_time: SKIP, update_time: SKIP, custom_id: SKIP,
               plan_overridden: SKIP, plan: SKIP, links: SKIP)
  @id = id unless id == SKIP
  @plan_id = plan_id unless plan_id == SKIP
  @start_time = start_time unless start_time == SKIP
  @quantity = quantity unless quantity == SKIP
  @shipping_amount = shipping_amount unless shipping_amount == SKIP
  @subscriber = subscriber unless subscriber == SKIP
  @billing_info = billing_info unless billing_info == SKIP
  @create_time = create_time unless create_time == SKIP
  @update_time = update_time unless update_time == SKIP
  @custom_id = custom_id unless custom_id == SKIP
  @plan_overridden = plan_overridden unless plan_overridden == SKIP
  @plan = plan unless plan == SKIP
  @links = links unless links == SKIP
end

Instance Attribute Details

#billing_infoSubscriptionBillingInformation

The billing details for the subscription. If the subscription was or is active, these fields are populated.



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

def billing_info
  @billing_info
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)


50
51
52
# File 'lib/paypal_server_sdk/models/subscription.rb', line 50

def create_time
  @create_time
end

#custom_idString

The custom id for the subscription. Can be invoice id.

Returns:

  • (String)


61
62
63
# File 'lib/paypal_server_sdk/models/subscription.rb', line 61

def custom_id
  @custom_id
end

#idString

The PayPal-generated ID for the subscription.

Returns:

  • (String)


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

def id
  @id
end

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

Returns:



74
75
76
# File 'lib/paypal_server_sdk/models/subscription.rb', line 74

def links
  @links
end

#planPlanDetails

The plan details.

Returns:



69
70
71
# File 'lib/paypal_server_sdk/models/subscription.rb', line 69

def plan
  @plan
end

#plan_idString

The ID of the plan.

Returns:

  • (String)


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

def plan_id
  @plan_id
end

#plan_overriddenTrueClass | FalseClass

Indicates whether the subscription has overridden any plan attributes.

Returns:

  • (TrueClass | FalseClass)


65
66
67
# File 'lib/paypal_server_sdk/models/subscription.rb', line 65

def plan_overridden
  @plan_overridden
end

#quantityString

The quantity of the product in the subscription.

Returns:

  • (String)


29
30
31
# File 'lib/paypal_server_sdk/models/subscription.rb', line 29

def quantity
  @quantity
end

#shipping_amountMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



34
35
36
# File 'lib/paypal_server_sdk/models/subscription.rb', line 34

def shipping_amount
  @shipping_amount
end

#start_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)


25
26
27
# File 'lib/paypal_server_sdk/models/subscription.rb', line 25

def start_time
  @start_time
end

#subscriberSubscriber

The subscriber response information.

Returns:



38
39
40
# File 'lib/paypal_server_sdk/models/subscription.rb', line 38

def subscriber
  @subscriber
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)


57
58
59
# File 'lib/paypal_server_sdk/models/subscription.rb', line 57

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/paypal_server_sdk/models/subscription.rb', line 139

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  plan_id = hash.key?('plan_id') ? hash['plan_id'] : SKIP
  start_time = hash.key?('start_time') ? hash['start_time'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  shipping_amount = Money.from_hash(hash['shipping_amount']) if hash['shipping_amount']
  subscriber = Subscriber.from_hash(hash['subscriber']) if hash['subscriber']
  billing_info = SubscriptionBillingInformation.from_hash(hash['billing_info']) if
    hash['billing_info']
  create_time = hash.key?('create_time') ? hash['create_time'] : SKIP
  update_time = hash.key?('update_time') ? hash['update_time'] : SKIP
  custom_id = hash.key?('custom_id') ? hash['custom_id'] : SKIP
  plan_overridden =
    hash.key?('plan_overridden') ? hash['plan_overridden'] : SKIP
  plan = PlanDetails.from_hash(hash['plan']) if hash['plan']
  # 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.
  Subscription.new(id: id,
                   plan_id: plan_id,
                   start_time: start_time,
                   quantity: quantity,
                   shipping_amount: shipping_amount,
                   subscriber: subscriber,
                   billing_info: billing_info,
                   create_time: create_time,
                   update_time: update_time,
                   custom_id: custom_id,
                   plan_overridden: plan_overridden,
                   plan: plan,
                   links: links)
end

.namesObject

A mapping from model property names to API property names.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/paypal_server_sdk/models/subscription.rb', line 77

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['plan_id'] = 'plan_id'
  @_hash['start_time'] = 'start_time'
  @_hash['quantity'] = 'quantity'
  @_hash['shipping_amount'] = 'shipping_amount'
  @_hash['subscriber'] = 'subscriber'
  @_hash['billing_info'] = 'billing_info'
  @_hash['create_time'] = 'create_time'
  @_hash['update_time'] = 'update_time'
  @_hash['custom_id'] = 'custom_id'
  @_hash['plan_overridden'] = 'plan_overridden'
  @_hash['plan'] = 'plan'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



115
116
117
# File 'lib/paypal_server_sdk/models/subscription.rb', line 115

def self.nullables
  []
end

.optionalsObject

An array for optional fields



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/paypal_server_sdk/models/subscription.rb', line 96

def self.optionals
  %w[
    id
    plan_id
    start_time
    quantity
    shipping_amount
    subscriber
    billing_info
    create_time
    update_time
    custom_id
    plan_overridden
    plan
    links
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



195
196
197
198
199
200
201
202
203
# File 'lib/paypal_server_sdk/models/subscription.rb', line 195

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, plan_id: #{@plan_id.inspect}, start_time:"\
  " #{@start_time.inspect}, quantity: #{@quantity.inspect}, shipping_amount:"\
  " #{@shipping_amount.inspect}, subscriber: #{@subscriber.inspect}, billing_info:"\
  " #{@billing_info.inspect}, create_time: #{@create_time.inspect}, update_time:"\
  " #{@update_time.inspect}, custom_id: #{@custom_id.inspect}, plan_overridden:"\
  " #{@plan_overridden.inspect}, plan: #{@plan.inspect}, links: #{@links.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



185
186
187
188
189
190
191
192
# File 'lib/paypal_server_sdk/models/subscription.rb', line 185

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, plan_id: #{@plan_id}, start_time: #{@start_time}, quantity:"\
  " #{@quantity}, shipping_amount: #{@shipping_amount}, subscriber: #{@subscriber},"\
  " billing_info: #{@billing_info}, create_time: #{@create_time}, update_time:"\
  " #{@update_time}, custom_id: #{@custom_id}, plan_overridden: #{@plan_overridden}, plan:"\
  " #{@plan}, links: #{@links}>"
end