Class: PaypalServerSdk::SubscriptionPatchApplicationContext

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

Overview

The application context, which customizes the payer experience during the subscription approval process with PayPal.

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(return_url:, cancel_url:, brand_name: SKIP, locale: SKIP, shipping_preference: ExperienceContextShippingPreference::GET_FROM_FILE, payment_method: SKIP) ⇒ SubscriptionPatchApplicationContext

Returns a new instance of SubscriptionPatchApplicationContext.



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 70

def initialize(
  return_url:, cancel_url:, brand_name: SKIP, locale: SKIP,
  shipping_preference: ExperienceContextShippingPreference::GET_FROM_FILE,
  payment_method: SKIP
)
  @brand_name = brand_name unless brand_name == SKIP
  @locale = locale unless locale == SKIP
  @shipping_preference = shipping_preference unless shipping_preference == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @return_url = return_url
  @cancel_url = cancel_url
end

Instance Attribute Details

#brand_nameString

The label that overrides the business name in the PayPal account on the PayPal site.

Returns:

  • (String)


16
17
18
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 16

def brand_name
  @brand_name
end

#cancel_urlString

The URL where the customer is redirected after the customer cancels the payment.

Returns:

  • (String)


41
42
43
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 41

def cancel_url
  @cancel_url
end

#localeString

The BCP 47-formatted locale of pages that the PayPal payment experience shows. PayPal supports a five-character code. For example, ‘da-DK`, `he-IL`, `id-ID`, `ja-JP`, `no-NO`, `pt-BR`, `ru-RU`, `sv-SE`, `th-TH`, `zh-CN`, `zh-HK`, or `zh-TW`.

Returns:

  • (String)


23
24
25
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 23

def locale
  @locale
end

#payment_methodPaymentMethod

The customer and merchant payment preferences.

Returns:



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

def payment_method
  @payment_method
end

#return_urlString

The URL where the customer is redirected after the customer approves the payment.

Returns:

  • (String)


36
37
38
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 36

def return_url
  @return_url
end

#shipping_preferenceExperienceContextShippingPreference

The location from which the shipping address is derived.



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

def shipping_preference
  @shipping_preference
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  return_url = hash.key?('return_url') ? hash['return_url'] : nil
  cancel_url = hash.key?('cancel_url') ? hash['cancel_url'] : nil
  brand_name = hash.key?('brand_name') ? hash['brand_name'] : SKIP
  locale = hash.key?('locale') ? hash['locale'] : SKIP
  shipping_preference =
    hash['shipping_preference'] ||= ExperienceContextShippingPreference::GET_FROM_FILE
  payment_method = PaymentMethod.from_hash(hash['payment_method']) if hash['payment_method']

  # Create object from extracted values.
  SubscriptionPatchApplicationContext.new(return_url: return_url,
                                          cancel_url: cancel_url,
                                          brand_name: brand_name,
                                          locale: locale,
                                          shipping_preference: shipping_preference,
                                          payment_method: payment_method)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['brand_name'] = 'brand_name'
  @_hash['locale'] = 'locale'
  @_hash['shipping_preference'] = 'shipping_preference'
  @_hash['payment_method'] = 'payment_method'
  @_hash['return_url'] = 'return_url'
  @_hash['cancel_url'] = 'cancel_url'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 56

def self.optionals
  %w[
    brand_name
    locale
    shipping_preference
    payment_method
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
120
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} brand_name: #{@brand_name.inspect}, locale: #{@locale.inspect},"\
  " shipping_preference: #{@shipping_preference.inspect}, payment_method:"\
  " #{@payment_method.inspect}, return_url: #{@return_url.inspect}, cancel_url:"\
  " #{@cancel_url.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



106
107
108
109
110
111
# File 'lib/paypal_server_sdk/models/subscription_patch_application_context.rb', line 106

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} brand_name: #{@brand_name}, locale: #{@locale}, shipping_preference:"\
  " #{@shipping_preference}, payment_method: #{@payment_method}, return_url: #{@return_url},"\
  " cancel_url: #{@cancel_url}>"
end