Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
B
bunqapi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sybren A. Stüvel
bunqapi
Commits
30099072
Commit
30099072
authored
May 23, 2019
by
Sybren A. Stüvel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt at creating payment requests
parent
2db86e05
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
9 deletions
+153
-9
model.go
model.go
+20
-0
monetary_account.go
monetary_account.go
+8
-1
query_account/query_account.go
query_account/query_account.go
+28
-7
request_inquiry.go
request_inquiry.go
+88
-0
session.go
session.go
+1
-1
user_info.go
user_info.go
+8
-0
No files found.
model.go
View file @
30099072
...
...
@@ -32,6 +32,26 @@ type BunqID struct {
ID
int
`json:"id"`
}
type
wrappedIDResponse
struct
{
Response
[]
idResponse
`json:"Response"`
}
type
idResponse
struct
{
ID
BunqID
`json:"Id"`
}
type
Geolocation
struct
{
Latitude
int
`json:"latitude"`
Longitude
int
`json:"longitude"`
Altitude
int
`json:"altitude"`
Radius
int
`json:"radius"`
}
type
Pointer
struct
{
Type
string
`json:"type,omitempty"`
Value
string
`json:"value,omitempty"`
Name
string
`json:"name,omitempty"`
}
type
ErrorResponse
struct
{
Error
[]
struct
{
Description
string
`json:"error_description"`
...
...
monetary_account.go
View file @
30099072
...
...
@@ -69,13 +69,20 @@ type MonetaryAccountSetting struct {
RestrictionChat
string
`json:"restriction_chat"`
}
func
(
c
*
Client
)
GetMonetaryAccountBankList
()
{
func
(
c
*
Client
)
GetMonetaryAccountBankList
()
[]
MonetaryAccountBank
{
wrappedResponse
:=
wrappedMonetaryAccountBankResponse
{}
url
:=
fmt
.
Sprintf
(
"user/%d/monetary-account-bank"
,
c
.
session
.
UserPerson
.
ID
)
errResp
:=
c
.
DoRequest
(
"GET"
,
url
,
nil
,
&
wrappedResponse
)
if
errResp
!=
nil
{
log
.
WithFields
(
errResp
.
LogFields
())
.
Fatal
(
"error performing session creation request"
)
}
accounts
:=
[]
MonetaryAccountBank
{}
for
index
:=
range
wrappedResponse
.
Response
{
accounts
=
append
(
accounts
,
wrappedResponse
.
Response
[
index
]
.
MonetaryAccountBank
)
}
return
accounts
}
func
(
c
*
Client
)
CreateMonetaryAccountBank
(
account
MonetaryAccountBank
)
{
...
...
query_account/query_account.go
View file @
30099072
...
...
@@ -48,11 +48,32 @@ func main() {
client
.
SessionStart
()
defer
client
.
SessionStop
()
// bankAccount := bunqapi.MonetaryAccountBank{
// Currency: "EUR",
// Description: "met geld er op?",
// Balance: &bunqapi.Amount{Value: "1033.41", Currency: "EUR"},
// }
// client.CreateMonetaryAccountBank(bankAccount)
client
.
GetMonetaryAccountBankList
()
// Find accounts to toy with.
accounts
:=
client
.
GetMonetaryAccountBankList
()
for
len
(
accounts
)
<
2
{
logrus
.
Warning
(
"not enough bank accounts, creating one"
)
bankAccount
:=
bunqapi
.
MonetaryAccountBank
{
Currency
:
"EUR"
,
}
client
.
CreateMonetaryAccountBank
(
bankAccount
)
accounts
=
client
.
GetMonetaryAccountBankList
()
}
logrus
.
WithField
(
"numAccounts"
,
len
(
accounts
))
.
Info
(
"enough bank accounts found"
)
// Request some money
rfp
:=
bunqapi
.
RequestInquiry
{
AmountInquired
:
&
bunqapi
.
Amount
{
Value
:
"300.00"
,
Currency
:
"EUR"
},
Description
:
"Daddy daddy can I play?"
,
AllowBunqme
:
true
,
CounterpartyAlias
:
&
bunqapi
.
LabelMonetaryAccount
{
BunqMe
:
&
bunqapi
.
Pointer
{
Type
:
"EMAIL"
,
Value
:
"sugardaddy@bunq.com"
,
},
},
}
client
.
CreateRequestInquiry
(
accounts
[
0
]
.
ID
,
rfp
)
}
request_inquiry.go
0 → 100644
View file @
30099072
/* (c) 2019 dr. Sybren A. Stüvel
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package
bunqapi
import
"fmt"
// RequestInquiry is a request-for-payment (RFP)
type
RequestInquiry
struct
{
AmountInquired
*
Amount
`json:"amount_inquired,omitempty"`
CounterpartyAlias
*
LabelMonetaryAccount
`json:"counterparty_alias,omitempty"`
Description
string
`json:"description,omitempty"`
Attachment
[]
BunqID
`json:"attachment,omitempty"`
MerchantReference
string
`json:"merchant_reference,omitempty"`
Status
string
`json:"status,omitempty"`
MinimumAge
int
`json:"minimum_age,omitempty"`
RequireAddress
string
`json:"require_address,omitempty"`
AllowBunqme
bool
`json:"allow_bunqme"`
RedirectURL
string
`json:"redirect_url,omitempty"`
EventID
int
`json:"event_id,omitempty"`
ID
int
`json:"id,omitempty"`
Created
string
`json:"created,omitempty"`
Updated
string
`json:"updated,omitempty"`
TimeResponded
string
`json:"time_responded,omitempty"`
TimeExpiry
string
`json:"time_expiry,omitempty"`
MonetaryAccountID
int
`json:"monetary_account_id,omitempty"`
AmountResponded
*
Amount
`json:"amount_responded,omitempty"`
UserAliasCreated
*
LabelUser
`json:"user_alias_created,omitempty"`
UserAliasRevoked
*
LabelUser
`json:"user_alias_revoked,omitempty"`
BatchID
int
`json:"batch_id,omitempty"`
ScheduledID
int
`json:"scheduled_id,omitempty"`
BunqmeShareURL
string
`json:"bunqme_share_url,omitempty"`
AddressShipping
*
Address
`json:"address_shipping,omitempty"`
AddressBilling
*
Address
`json:"address_billing,omitempty"`
Geolocation
*
Geolocation
`json:"geolocation,omitempty"`
AllowChat
bool
`json:"allow_chat,omitempty"`
// Not yet implemented:
// ReferenceSplitTheBill *RequestReferenceSplitTheBillAnchorObject `json:"reference_split_the_bill,omitempty"`
}
type
LabelMonetaryAccount
struct
{
IBAN
string
`json:"iban,omitempty"`
DisplayName
string
`json:"display_name,omitempty"`
Avatar
*
Avatar
`json:"avatar,omitempty"`
LabelUser
*
LabelUser
`json:"label_user,omitempty"`
Country
string
`json:"country,omitempty"`
BunqMe
*
Pointer
`json:"bunq_me,omitempty"`
IsLight
bool
`json:"is_light,omitempty"`
SwiftBic
string
`json:"swift_bic,omitempty"`
SwiftAccountNumber
string
`json:"swift_account_number,omitempty"`
TransferwiseAccountNumber
string
`json:"transferwise_account_number,omitempty"`
TransferwiseBankCode
string
`json:"transferwise_bank_code,omitempty"`
}
func
(
c
*
Client
)
CreateRequestInquiry
(
monetaryAccountID
int
,
rfp
RequestInquiry
)
int
{
wrappedResponse
:=
wrappedIDResponse
{}
url
:=
fmt
.
Sprintf
(
"user/%d/monetary-account/%d/request-inquiry"
,
c
.
session
.
UserPerson
.
ID
,
monetaryAccountID
)
errResp
:=
c
.
DoRequest
(
"POST"
,
url
,
&
rfp
,
&
wrappedResponse
)
if
errResp
!=
nil
{
log
.
WithFields
(
errResp
.
LogFields
())
.
Fatal
(
"error performing request inquiry creation request"
)
}
response
:=
idResponse
{}
MergeStructs
(
wrappedResponse
.
Response
,
&
response
)
log
.
WithField
(
"requestInquiryID"
,
response
.
ID
.
ID
)
.
Info
(
"payment request created"
)
return
response
.
ID
.
ID
}
session.go
View file @
30099072
...
...
@@ -83,7 +83,7 @@ func (c *Client) SessionStart() {
func
(
c
*
Client
)
SessionStop
()
{
logger
:=
log
.
WithField
(
"sessionID"
,
c
.
session
.
ID
)
logger
.
Info
(
"closing session"
)
logger
.
Debug
(
"closing session"
)
url
:=
fmt
.
Sprintf
(
"session/%d"
,
c
.
session
.
ID
)
errResp
:=
c
.
DoRequest
(
"DELETE"
,
url
,
nil
,
nil
)
...
...
user_info.go
View file @
30099072
...
...
@@ -139,3 +139,11 @@ type UserPerson struct {
Avatar
Avatar
`json:"avatar"`
VersionTermsOfService
string
`json:"version_terms_of_service"`
}
type
LabelUser
struct
{
UUID
string
`json:"uuid,omitempty"`
DisplayName
string
`json:"display_name,omitempty"`
Country
string
`json:"country,omitempty"`
Avatar
*
Avatar
`json:"avatar,omitempty"`
PublicNickName
string
`json:"public_nick_name,omitempty"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment