Class: BloomRemit2::Sender

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, email = nil, first_name = nil, last_name = nil, passport_number = nil, passport_expiry_date = nil, tin = nil, mobile = nil, address = nil, city = nil, state = nil, zip_code = nil, country = nil, birthdate = nil, photo_uid = nil, photo_name = nil, id_photo_uid = nil, id_photo_name = nil, identification_type = nil, identification_number = nil, identification_details = nil, deleted_at = nil, dragonpay_userid = nil, sending_level = nil, occupation = nil, created_at = nil, updated_at = nil, deleted: false) ⇒ Sender

Returns a new instance of Sender.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/bloom_remit2/sender.rb', line 108

def initialize(
  id,
  email=nil,
  first_name=nil,
  last_name=nil,
  passport_number=nil,
  passport_expiry_date=nil,
  tin=nil,
  mobile=nil,
  address=nil,
  city=nil,
  state=nil,
  zip_code=nil,
  country=nil,
  birthdate=nil,
  photo_uid=nil,
  photo_name=nil,
  id_photo_uid=nil,
  id_photo_name=nil,
  identification_type=nil,
  identification_number=nil,
  identification_details=nil,
  deleted_at=nil,
  dragonpay_userid=nil,
  sending_level=nil,
  occupation=nil,
  created_at=nil,
  updated_at=nil,
  deleted: false
)
  @id = id
  @email = email
  @first_name = first_name
  @last_name = last_name
  @passport_number = passport_number
  @passport_expiry_date = passport_expiry_date
  @tin = tin
  @mobile = mobile
  @address = address
  @city = city
  @state = state
  @zip_code = zip_code
  @country = country
  @birthdate = birthdate
  @photo_uid = photo_uid
  @photo_name = photo_name
  @id_photo_uid = id_photo_uid
  @id_photo_name = id_photo_name
  @identification_type = identification_type
  @identification_number = identification_number
  @identification_details = identification_details
  @deleted_at = deleted_at
  @dragonpay_userid = dragonpay_userid
  @sending_level = sending_level
  @occupation = occupation
  @created_at = created_at
  @updated_at = updated_at
  @deleted = deleted
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def address
  @address
end

#birthdateObject (readonly)

Returns the value of attribute birthdate.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def birthdate
  @birthdate
end

#cityObject (readonly)

Returns the value of attribute city.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def city
  @city
end

#countryObject (readonly)

Returns the value of attribute country.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def country
  @country
end

#created_atObject (readonly)

Returns the value of attribute created_at.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def created_at
  @created_at
end

#deletedObject (readonly)

Returns the value of attribute deleted.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def deleted
  @deleted
end

#deleted_atObject (readonly)

Returns the value of attribute deleted_at.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def deleted_at
  @deleted_at
end

#dragonpay_useridObject (readonly)

Returns the value of attribute dragonpay_userid.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def dragonpay_userid
  @dragonpay_userid
end

#emailObject (readonly)

Returns the value of attribute email.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def id
  @id
end

#id_photo_nameObject (readonly)

Returns the value of attribute id_photo_name.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def id_photo_name
  @id_photo_name
end

#id_photo_uidObject (readonly)

Returns the value of attribute id_photo_uid.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def id_photo_uid
  @id_photo_uid
end

#identification_detailsObject (readonly)

Returns the value of attribute identification_details.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def identification_details
  @identification_details
end

#identification_numberObject (readonly)

Returns the value of attribute identification_number.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def identification_number
  @identification_number
end

#identification_typeObject (readonly)

Returns the value of attribute identification_type.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def identification_type
  @identification_type
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def last_name
  @last_name
end

#mobileObject (readonly)

Returns the value of attribute mobile.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def mobile
  @mobile
end

#passport_expiry_dateObject (readonly)

Returns the value of attribute passport_expiry_date.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def passport_expiry_date
  @passport_expiry_date
end

#passport_numberObject (readonly)

Returns the value of attribute passport_number.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def passport_number
  @passport_number
end

#photo_nameObject (readonly)

Returns the value of attribute photo_name.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def photo_name
  @photo_name
end

#photo_uidObject (readonly)

Returns the value of attribute photo_uid.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def photo_uid
  @photo_uid
end

#sending_levelObject (readonly)

Returns the value of attribute sending_level.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def sending_level
  @sending_level
end

#stateObject (readonly)

Returns the value of attribute state.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def state
  @state
end

#tinObject (readonly)

Returns the value of attribute tin.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def tin
  @tin
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def updated_at
  @updated_at
end

#zip_codeObject (readonly)

Returns the value of attribute zip_code.



106
107
108
# File 'lib/bloom_remit2/sender.rb', line 106

def zip_code
  @zip_code
end

Class Method Details

.create(sender_hash) ⇒ Object

Create a new sender under this partner



36
37
38
39
# File 'lib/bloom_remit2/sender.rb', line 36

def create(sender_hash)
  sender = Client.post(path, sender_hash)
  initialize_from_hash(sender['sender'])
end

.delete(sender_id) ⇒ Object

Delete a sender belonging to this partner

Parameters:

  • sender_id (String)

    id of sender to delete



56
57
58
59
60
61
62
63
64
# File 'lib/bloom_remit2/sender.rb', line 56

def delete(sender_id)
  message = Client.delete("#{path}/#{sender_id}").with_indifferent_access
  if message[:success] == "We've successfully deleted that user."
    new(
      sender_id,
      deleted: true
    )
  end
end

.find_by_email(email) ⇒ Object

Show a sender belonging to this partner by supplying their email address

Parameters:

  • email (String)


21
22
23
24
# File 'lib/bloom_remit2/sender.rb', line 21

def find_by_email(email)
  sender = Client.get("#{path}/find_by_email", query: { email: email })
  initialize_from_hash(sender['user'])
end

.listObject

Show a list of senders belonging to this partner



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

def list
  senders = Client.get(path)
  senders.map { |sender| initialize_from_hash(sender) }
end

.retrieve(id) ⇒ Object

Show a sender belonging to this partner



13
14
15
16
# File 'lib/bloom_remit2/sender.rb', line 13

def retrieve(id)
  sender = Client.get("#{path}/#{id}")
  initialize_from_hash(sender['user'])
end

.update(sender_id, sender_hash) ⇒ Object

Update the attributes of a sender belonging to this partner TODO: Doesn’t support identification or proof of address

Parameters:

  • sender_id (String)

    id of the sender to update

  • sender_hash (Hash)

    attributes to update sender



45
46
47
48
49
50
51
52
# File 'lib/bloom_remit2/sender.rb', line 45

def update(sender_id, sender_hash)
  body = []
  sender_hash.each do |k, v|
    body << ["user[#{k.to_s.downcase}]", v]
  end
  sender = Client.put("#{path}/#{sender_id}", body)
  initialize_from_hash(sender['user'])
end