Class: PFS::API::AccountsService

Inherits:
Service
  • Object
show all
Defined in:
lib/pfs/api/accounts_service.rb

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from PFS::API::Service

Instance Method Details

#balance(account_id) ⇒ Object



6
7
8
9
# File 'lib/pfs/api/accounts_service.rb', line 6

def balance()
  response = client.get("/Account/#{}/Balance")
  Resources::Accounts::Balance.new(response, response.body[:data])
end

#close(account_id:) ⇒ Object



53
54
55
# File 'lib/pfs/api/accounts_service.rb', line 53

def close(account_id: )
  update_status(account_id: , status_code: PFS::Resources::Accounts::Status::CODES[:closed])
end

#credit(account_id, currency, amount, fee_code = "**API", description = "Deposit To Card API") ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/pfs/api/accounts_service.rb', line 57

def credit(, currency, amount, fee_code = "**API", description = "Deposit To Card API")
  attributes = {
    amount: amount,
    currencyCode: currency,
    feeCode: fee_code,
    transactionDescription: description,
  }
  response = client.post("/Account/#{}/Balance/Credit", attributes)
  Resources::Accounts::BalanceCredit.new(response, response.body[:data])
end

#info(account_id:) ⇒ Object



35
36
37
38
# File 'lib/pfs/api/accounts_service.rb', line 35

def info(account_id: )
  response = client.get("/Account/#{}")
  Resources::Accounts::Account.new(response, response.body[:data])
end

#issue(bin:, dc:, style:, incorporation_date:, company_name:, first_name:, last_name:, address:, postal_code:, city:, state:, country:, user_defined1: nil, user_defined2: nil, user_defined3: nil, user_defined4: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pfs/api/accounts_service.rb', line 11

def issue(bin:, dc:, style: ,incorporation_date:, company_name:, first_name:, last_name:, address:, postal_code: , city:, state:, country:,  user_defined1: nil, user_defined2: nil, user_defined3: nil, user_defined4: nil)
  attributes = {
    bin: bin,
    distributorcode: dc,
    cardstyle: style,
    companyname: company_name,
    firstname: first_name,
    lastname: last_name,
    dateofbirth: incorporation_date,
    address1: address,
    city: city,
    county: state,
    zipcode: postal_code,
    countrycode: country,
  }
  attributes[:userdefined1] = user_defined1 if user_defined1
  attributes[:userdefined2] = user_defined2 if user_defined2
  attributes[:userdefined3] = user_defined3 if user_defined3
  attributes[:userdefined4] = user_defined4 if user_defined4

  response = client.post("/Account", attributes)
  Resources::Accounts::IssuedAccount.new(response, response.body[:data])
end

#status(account_id:) ⇒ Object



40
41
42
43
# File 'lib/pfs/api/accounts_service.rb', line 40

def status(account_id: )
  response = client.get("/Account/#{}/Status")
  Resources::Accounts::Status.new(response, response.body[:data])
end

#update_status(account_id:, status_code:) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/pfs/api/accounts_service.rb', line 45

def update_status(account_id: , status_code: )
  attributes = {
    status: status_code,
  }
  client.patch("/Account/#{}/Status", attributes)
  status(account_id: )
end