class Paymill::Checksum

Attributes

action[R]
app_id[R]
checksum[R]
created_at[R]
data[R]
id[R]
items[R]
shipping_address[R]
type[R]
updated_at[R]

Public Class Methods

new( json ) click to toggle source
# File lib/paymill/models/checksum.rb, line 7
def initialize( json )
  deserialize( json )
  parse_timestamps
end

Protected Class Methods

allowed_arguments() click to toggle source
# File lib/paymill/models/checksum.rb, line 18
def self.allowed_arguments
  [
    :checksum_type, :amount, :currency, :return_url, :cancel_url, :description,
    :shipping_address, :billing_address, :items, :shipping_amount, :handling_amount, :client_id,
    :require_reusable_payment, :reusable_payment_description,
    :fee_amount, :fee_payment, :fee_currency, :app_id
  ]
end
create_with?( incoming_arguments ) click to toggle source
# File lib/paymill/models/checksum.rb, line 13
def self.create_with?( incoming_arguments )
  return false if mandatory_arguments.select { |a| incoming_arguments.include? a }.size < mandatory_arguments.size
  allowed_arguments.size == ( allowed_arguments | incoming_arguments ).size
end
mandatory_arguments() click to toggle source
# File lib/paymill/models/checksum.rb, line 27
def self.mandatory_arguments
  [:checksum_type, :amount, :currency, :return_url, :cancel_url]
end

Protected Instance Methods

parse_timestamps() click to toggle source

Parses UNIX timestamps and creates Time objects.

# File lib/paymill/models/checksum.rb, line 32
def parse_timestamps
  @created_at &&= Time.at( @created_at )
  @updated_at &&= Time.at( @updated_at )
end

Private Instance Methods

deserialize( json ) click to toggle source
# File lib/paymill/models/checksum.rb, line 38
def deserialize( json )
  json.each_pair do |key, value|
    instance_variable_set( "@#{key}", (Integer( value ) rescue value) )
  end
end