forked from gotsunami/mangopay2-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
59 lines (51 loc) · 1.25 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2014 Mathias Monnerville. All rights reserved.
// Use of this source code is governed by a GPL
// license that can be found in the LICENSE file.
package mango
import (
"time"
)
// See http://docs.mangopay.com/api-references/events/.
// An event ressource.
type Event struct {
RessourceId string
Type EventType `json:"EventType"`
Date *time.Time
}
type EventList []*Event
type EventType int
const (
PAYIN_NORMAL_CREATED EventType = iota
PAYIN_NORMAL_SUCCEEDED
PAYIN_NORMAL_FAILED
PAYOUT_NORMAL_CREATED
PAYOUT_NORMAL_SUCCEEDED
PAYOUT_NORMAL_FAILED
TRANSFER_NORMAL_CREATED
TRANSFER_NORMAL_SUCCEEDED
TRANSFER_NORMAL_FAILED
PAYIN_REFUND_CREATED
PAYIN_REFUND_SUCCEEDED
PAYIN_REFUND_FAILED
PAYOUT_REFUND_CREATED
PAYOUT_REFUND_SUCCEEDED
PAYOUT_REFUND_FAILED
TRANSFER_REFUND_CREATED
TRANSFER_REFUND_SUCCEEDED
TRANSFER_REFUND_FAILED
)
// Events returns a list of all financial events. This include PayIns, PayOuts and
// transfers.
//
// TODO: add support for pagination and date range.
func (m *MangoPay) Events() (EventList, error) {
es := EventList{}
resp, err := m.request(actionEvents, nil)
if err != nil {
return nil, err
}
if err := m.unMarshalJSONResponse(resp, &es); err != nil {
return nil, err
}
return es, err
}