Class: MonoRuby::Mono

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mono_ruby.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Mono

Returns a new instance of Mono.



11
12
13
# File 'lib/mono_ruby.rb', line 11

def initialize(data)
    @options = { headers: { "Content-Type": "application/json", "mono-sec-key": data["secretKey"] } }
end

Instance Method Details

#getAccountId(data) ⇒ Object



19
20
21
# File 'lib/mono_ruby.rb', line 19

def getAccountId(data)
    self.class.post("/account/auth", @options.merge!( body: {code: data["code"]}.to_json ))
end

#getAccountInformation(data) ⇒ Object



23
24
25
# File 'lib/mono_ruby.rb', line 23

def getAccountInformation(data)
    self.class.get("/accounts/#{data["accountId"]}", @options)
end

#getAccountStatement(data) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/mono_ruby.rb', line 27

def getAccountStatement(data)
    query = "?"
    query += data["period"] ? "period=#{data["period"]}&" : ''
    query += data["output"] ? "output=#{data["output"]}&" : ''
    
    self.class.get("/accounts/#{data["accountId"]}/statement#{query}", @options)
end

#getAccountTransactions(data) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mono_ruby.rb', line 39

def getAccountTransactions(data)
    query = "?"
    query += data["start"] ? "start=#{data["start"]}&" : ''
    query += data["end"] ? "end=#{data["end"]}&" : ''
    query += data["narration"] ? "narration=#{data["narration"]}&" : ''
    query += data["type"] ? "type=#{data["type"]}&" : '';
    query += (!data["paginate"] && data["paginate"] === false) ? "paginate=false&" : "paginate=true&"
    query += data["limit"] ? "limit=#{data["limit"]}&" : ''
    
    self.class.get("/accounts/#{data["accountId"]}/transactions#{query}", @options)
end

#getIdentity(data) ⇒ Object



55
56
57
# File 'lib/mono_ruby.rb', line 55

def getIdentity(data)
    self.class.get("/accounts/#{data["accountId"]}/identity", @options)
end

#getIncome(data) ⇒ Object



51
52
53
# File 'lib/mono_ruby.rb', line 51

def getIncome(data)
    self.class.get("/accounts/#{data["accountId"]}/income", @options)
end

#getInstitutionsObject



67
68
69
# File 'lib/mono_ruby.rb', line 67

def getInstitutions
    self.class.get("/coverage", @options)
end

#getWalletBalanceObject



15
16
17
# File 'lib/mono_ruby.rb', line 15

def getWalletBalance
    self.class.get("/users/stats/wallet", @options)
end

#pollPdfAccountStatementStatus(data) ⇒ Object



35
36
37
# File 'lib/mono_ruby.rb', line 35

def pollPdfAccountStatementStatus(data)
    self.class.get("/accounts/#{data["accountId"]}/statement/jobs/#{data["jobId"]}", @options)
end

#reauthCode(data) ⇒ Object



63
64
65
# File 'lib/mono_ruby.rb', line 63

def reauthCode(data)
    self.class.post("/accounts/#{data["accountId"]}/reauthorise", @options)
end

#syncDataManually(data) ⇒ Object



59
60
61
# File 'lib/mono_ruby.rb', line 59

def syncDataManually(data)
    self.class.post("/accounts/#{data["accountId"]}/sync", @options)
end

#unlinkAccount(data) ⇒ Object



71
72
73
# File 'lib/mono_ruby.rb', line 71

def unlinkAccount(data)
    self.class.post("/accounts/#{data["accountId"]}/unlink", @options)
end