Class: Cryptopay::SubscriptionParams

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/models/subscription_params.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SubscriptionParams

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



54
55
56
# File 'lib/cryptopay/models/subscription_params.rb', line 54

def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::SubscriptionParams

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



47
48
49
50
# File 'lib/cryptopay/models/subscription_params.rb', line 47

def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end

Instance Method Details

#amountObject

Subscription amount



64
65
66
# File 'lib/cryptopay/models/subscription_params.rb', line 64

def amount
  @attributes[:amount]
end

#currencyObject

Subscription amount currency



69
70
71
# File 'lib/cryptopay/models/subscription_params.rb', line 69

def currency
  @attributes[:currency]
end

#custom_idObject

Subscription reference ID in your system



96
97
98
# File 'lib/cryptopay/models/subscription_params.rb', line 96

def custom_id
  @attributes[:custom_id]
end

#inspectObject



155
156
157
# File 'lib/cryptopay/models/subscription_params.rb', line 155

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
end

#invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/cryptopay/models/subscription_params.rb', line 119

def invalid_properties
  properties = []

  properties.push('invalid value for "name", name cannot be nil.') if name.nil?

  properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil?

  properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?

  properties.push('invalid value for "period", period cannot be nil.') if period.nil?

  if !period.nil? && !%w[day week month year].include?(period)
    properties.push('invalid value for period, must be one of "day", "week", "month", "year"')
  end

  properties.push('invalid value for "period_quantity", period_quantity cannot be nil.') if period_quantity.nil?

  properties.push('invalid value for "starts_at", starts_at cannot be nil.') if starts_at.nil?

  properties.push('invalid value for "payer_email", payer_email cannot be nil.') if payer_email.nil?

  properties
end

#nameObject

Subscription name



59
60
61
# File 'lib/cryptopay/models/subscription_params.rb', line 59

def name
  @attributes[:name]
end

#payer_emailObject

Email of the payer



86
87
88
# File 'lib/cryptopay/models/subscription_params.rb', line 86

def payer_email
  @attributes[:payer_email]
end

#payer_nameObject

Name of the payer



91
92
93
# File 'lib/cryptopay/models/subscription_params.rb', line 91

def payer_name
  @attributes[:payer_name]
end

#periodObject



73
74
75
# File 'lib/cryptopay/models/subscription_params.rb', line 73

def period
  @attributes[:period]
end

#period_quantityObject



77
78
79
# File 'lib/cryptopay/models/subscription_params.rb', line 77

def period_quantity
  @attributes[:period_quantity]
end

#product_descriptionObject



104
105
106
# File 'lib/cryptopay/models/subscription_params.rb', line 104

def product_description
  @attributes[:product_description]
end

#product_nameObject



100
101
102
# File 'lib/cryptopay/models/subscription_params.rb', line 100

def product_name
  @attributes[:product_name]
end

#starts_atObject



81
82
83
# File 'lib/cryptopay/models/subscription_params.rb', line 81

def starts_at
  @attributes[:starts_at]
end

#success_redirect_urlObject

The URL that the customer will be redirected to upon transaction confirmation



109
110
111
# File 'lib/cryptopay/models/subscription_params.rb', line 109

def success_redirect_url
  @attributes[:success_redirect_url]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



151
152
153
# File 'lib/cryptopay/models/subscription_params.rb', line 151

def to_hash
  ENCODER.to_hash(@attributes)
end

#unsuccess_redirect_urlObject



113
114
115
# File 'lib/cryptopay/models/subscription_params.rb', line 113

def unsuccess_redirect_url
  @attributes[:unsuccess_redirect_url]
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



145
146
147
# File 'lib/cryptopay/models/subscription_params.rb', line 145

def valid?
  invalid_properties.empty?
end