Class: PaysonAPI::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/payson_api/sender.rb

Constant Summary collapse

FORMAT_STRING =
"sender%s"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, first_name, last_name) ⇒ Sender

Returns a new instance of Sender.



8
9
10
11
12
# File 'lib/payson_api/sender.rb', line 8

def initialize(email, first_name, last_name)
  @email = email
  @first_name = first_name
  @last_name = last_name
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/payson_api/sender.rb', line 6

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



6
7
8
# File 'lib/payson_api/sender.rb', line 6

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



6
7
8
# File 'lib/payson_api/sender.rb', line 6

def last_name
  @last_name
end

Class Method Details

.parse(data) ⇒ Object



22
23
24
25
26
27
# File 'lib/payson_api/sender.rb', line 22

def self.parse(data)
  email = data[FORMAT_STRING % 'email']
  first_name = CGI.unescape(data[FORMAT_STRING % 'FirstName'].to_s)
  last_name = CGI.unescape(data[FORMAT_STRING % 'LastName'].to_s)
  self.new(email, first_name, last_name)
end

Instance Method Details

#to_hashObject



14
15
16
17
18
19
20
# File 'lib/payson_api/sender.rb', line 14

def to_hash
  {}.tap do |hash|
    hash[FORMAT_STRING % 'Email'] = @email
    hash[FORMAT_STRING % 'FirstName'] = @first_name
    hash[FORMAT_STRING % 'LastName'] = @last_name
  end
end