GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( be3b80...df3f10 )
by
unknown
01:29
created

mollie.*WebhookEventService.Get   A

Complexity

Conditions 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
package mollie
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
7
	"time"
8
)
9
10
// WebhookEventService handles webhook event API calls.
11
type WebhookEventService service
12
13
// WebhookEntityLinks represents the links related to the entity received with a webhook event.
14
type WebhookEntityLinks struct {
15
	Self        *URL `json:"self,omitempty"`
16
	PaymentLink *URL `json:"paymentLink,omitempty"`
17
}
18
19
// WebhookEntity represents the entity received with a webhook event.
20
type WebhookEntity struct {
21
	Archived        bool                `json:"archived,omitempty"`
22
	Reusable        bool                `json:"reusable,omitempty"`
23
	CustomerID      string              `json:"customerId,omitempty"`
24
	ID              string              `json:"id,omitempty"`
25
	Description     string              `json:"description,omitempty"`
26
	ProfileID       string              `json:"profileId,omitempty"`
27
	RedirectURL     string              `json:"redirectUrl,omitempty"`
28
	Resource        string              `json:"resource,omitempty"`
29
	WebhookURL      string              `json:"webhookUrl,omitempty"`
30
	Amount          Amount              `json:"amount,omitempty"`
31
	ApplicationFee  ApplicationFee      `json:"applicationFee,omitempty"`
32
	MinimumAmount   Amount              `json:"minimumAmount,omitempty"`
33
	Mode            Mode                `json:"mode,omitempty"`
34
	SequenceType    SequenceType        `json:"sequenceType,omitempty"`
35
	AllowedMethods  []PaymentMethod     `json:"allowedMethods,omitempty"`
36
	Lines           []WebhookEntityLine `json:"lines,omitempty"`
37
	Links           WebhookEntityLinks  `json:"_links,omitempty"`
38
	BillingAddress  *Address            `json:"billingAddress,omitempty"`
39
	ShippingAddress *Address            `json:"shippingAddress,omitempty"`
40
	CreatedAt       *time.Time          `json:"createdAt,omitempty"`
41
	ExpiresAt       *time.Time          `json:"expiresAt,omitempty"`
42
	PaidAt          *time.Time          `json:"paidAt,omitempty"`
43
}
44
45
// WebhookEntityLine represents a line item in the entity received with a webhook event.
46
type WebhookEntityLine struct {
47
	Quantity       int               `json:"quantity,omitempty"`
48
	Description    string            `json:"description,omitempty"`
49
	ImageURL       string            `json:"imageUrl,omitempty"`
50
	ProductURL     string            `json:"productUrl,omitempty"`
51
	QuantityUnit   string            `json:"quantityUnit,omitempty"`
52
	SKU            string            `json:"sku,omitempty"`
53
	VATRate        string            `json:"vatRate,omitempty"`
54
	DiscountAmount Amount            `json:"discountAmount,omitempty"`
55
	Type           ProductKind       `json:"type,omitempty"`
56
	TotalAmount    Amount            `json:"totalAmount,omitempty"`
57
	UnitPrice      Amount            `json:"unitPrice,omitempty"`
58
	VATAmount      Amount            `json:"vatAmount,omitempty"`
59
	Categories     []VoucherCategory `json:"categories,omitempty"`
60
}
61
62
// WebhookEventLinks represents the links related to a webhook event.
63
type WebhookEventLinks struct {
64
	Self          *URL `json:"self,omitempty"`
65
	Documentation *URL `json:"documentation,omitempty"`
66
	Entity        *URL `json:"entity,omitempty"`
67
}
68
69
// WebhookEventEmbedded represents the embedded entity object in a webhook event.
70
type WebhookEventEmbedded struct {
71
	Entity WebhookEntity `json:"entity,omitempty"`
72
}
73
74
// WebhookEvent represents a webhook event received from Mollie.
75
type WebhookEvent struct {
76
	Resource  string               `json:"resource,omitempty"`
77
	ID        string               `json:"id,omitempty"`
78
	Type      string               `json:"type,omitempty"`
79
	EntityID  string               `json:"entityId,omitempty"`
80
	Embedded  WebhookEventEmbedded `json:"_embedded,omitempty"`
81
	Links     WebhookEventLinks    `json:"_links,omitempty"`
82
	CreatedAt *time.Time           `json:"createdAt,omitempty"`
83
}
84
85
// Get retrieves a webhook event by its ID.
86
//
87
// See: https://docs.mollie.com/reference/get-webhook-event
88
func (s *WebhookEventService) Get(ctx context.Context, eventID string) (res *Response, we *WebhookEvent, err error) {
89
	res, err = s.client.get(ctx, fmt.Sprintf("/v2/events/%s", eventID), nil)
90
	if err != nil {
91
		return
92
	}
93
94
	if err = json.Unmarshal(res.content, &we); err != nil {
95
		return
96
	}
97
98
	return
99
}
100