Class: PaypalServerSdk::PlanDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/plan_details.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(product_id: SKIP, name: SKIP, description: SKIP, billing_cycles: SKIP, payment_preferences: SKIP, merchant_preferences: SKIP, taxes: SKIP, quantity_supported: false) ⇒ PlanDetails

Returns a new instance of PlanDetails.



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

def initialize(product_id: SKIP, name: SKIP, description: SKIP,
               billing_cycles: SKIP, payment_preferences: SKIP,
               merchant_preferences: SKIP, taxes: SKIP,
               quantity_supported: false)
  @product_id = product_id unless product_id == SKIP
  @name = name unless name == 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
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:



27
28
29
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 27

def billing_cycles
  @billing_cycles
end

#descriptionString

The detailed description of the plan.

Returns:

  • (String)


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

def description
  @description
end

#merchant_preferencesMerchantPreferences

The merchant preferences for a subscription.

Returns:



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

def merchant_preferences
  @merchant_preferences
end

#nameString

The plan name.

Returns:

  • (String)


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

def name
  @name
end

#payment_preferencesPaymentPreferences

The payment preferences for a subscription.

Returns:



31
32
33
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 31

def payment_preferences
  @payment_preferences
end

#product_idString

The ID for the product.

Returns:

  • (String)


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

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)


44
45
46
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 44

def quantity_supported
  @quantity_supported
end

#taxesTaxes

The tax details.

Returns:



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

def taxes
  @taxes
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  name = hash.key?('name') ? hash['name'] : 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 object from extracted values.
  PlanDetails.new(product_id: product_id,
                  name: name,
                  description: description,
                  billing_cycles: billing_cycles,
                  payment_preferences: payment_preferences,
                  merchant_preferences: merchant_preferences,
                  taxes: taxes,
                  quantity_supported: quantity_supported)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_id'] = 'product_id'
  @_hash['name'] = 'name'
  @_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
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 61

def self.optionals
  %w[
    product_id
    name
    description
    billing_cycles
    payment_preferences
    merchant_preferences
    taxes
    quantity_supported
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



139
140
141
142
143
144
145
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 139

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} product_id: #{@product_id.inspect}, name: #{@name.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}>"
end

#to_sObject

Provides a human-readable string representation of the object.



130
131
132
133
134
135
136
# File 'lib/paypal_server_sdk/models/plan_details.rb', line 130

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