Passed
Push — main ( 2b8b96...6e7fbc )
by Acho
01:19
created

stubs.WebhookGetResponse   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package stubs
2
3
// WebhookRequestOrderCreated is a dummy webhook request
4
func WebhookRequestOrderCreated() []byte {
5
	return []byte(`
6
{
7
  "meta": {
8
    "event_name": "order_created",
9
	"custom_data": {
10
      "customer_id": 25
11
    }
12
  },
13
  "data": {
14
    "type": "orders",
15
    "id": "1",
16
    "attributes": {
17
      "store_id": 1,
18
      "customer_id": 1,
19
      "identifier": "89b36d62-4f5c-4353-853f-0c769d0535c8",
20
      "order_number": 1,
21
      "user_name": "Dan R",
22
      "user_email": "[email protected]",
23
      "currency": "EUR",
24
      "currency_rate": "1.08405",
25
      "subtotal": 1499,
26
      "discount_total": 0,
27
      "tax": 359,
28
      "total": 1859,
29
      "subtotal_usd": 1626,
30
      "discount_total_usd": 0,
31
      "tax_usd": 390,
32
      "total_usd": 2016,
33
      "tax_name": "ALV",
34
      "tax_rate": "24.00",
35
      "status": "paid",
36
      "status_formatted": "Paid",
37
      "refunded": null,
38
      "refunded_at": null,
39
      "subtotal_formatted": "€14.99",
40
      "discount_total_formatted": "€0.00",
41
      "tax_formatted": "€3.59",
42
      "total_formatted": "€18.59",
43
      "first_order_item": {
44
        "order_id": 1,
45
        "product_id": 1,
46
        "variant_id": 1,
47
        "product_name": "Product One",
48
        "variant_name": "Default",
49
        "price": 1500,
50
        "created_at": "2023-01-17T12:26:23.000000Z",
51
        "updated_at": "2023-01-17T12:26:23.000000Z",
52
        "test_mode": false
53
      },
54
      "urls": {
55
        "receipt": "https://app.lemonsqueezy.com/my-orders/89b36d62-4f5c-4353-853f-0c769d0535c8?signature=8847fff02e1bfb0c7c43ff1cdf1b1657a8eed2029413692663b86859208c9f42"
56
      },
57
      "created_at": "2023-01-17T12:26:23.000000Z",
58
      "updated_at": "2023-01-17T12:26:23.000000Z",
59
      "test_mode": false
60
    },
61
    "relationships": {
62
      "store": {
63
        "links": {
64
          "related": "https://api.lemonsqueezy.com/v1/orders/1/store",
65
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/store"
66
        }
67
      },
68
      "customer": {
69
        "links": {
70
          "related": "https://api.lemonsqueezy.com/v1/orders/1/customer",
71
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/customer"
72
        }
73
      },
74
      "order-items": {
75
        "links": {
76
          "related": "https://api.lemonsqueezy.com/v1/orders/1/order-items",
77
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/order-items"
78
        }
79
      },
80
      "subscriptions": {
81
        "links": {
82
          "related": "https://api.lemonsqueezy.com/v1/orders/1/subscriptions",
83
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/subscriptions"
84
        }
85
      },
86
      "license-keys": {
87
        "links": {
88
          "related": "https://api.lemonsqueezy.com/v1/orders/1/license-keys",
89
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/license-keys"
90
        }
91
      },
92
      "discount-redemptions": {
93
        "links": {
94
          "related": "https://api.lemonsqueezy.com/v1/orders/1/discount-redemptions",
95
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/discount-redemptions"
96
        }
97
      }
98
    },
99
    "links": {
100
      "self": "https://api.lemonsqueezy.com/v1/orders/1"
101
    }
102
  }
103
}
104
`)
105
}
106
107
// WebhookGetResponse is a dummy response to the GET /v1/webhooks/:id endpoint
108
func WebhookGetResponse() []byte {
109
	return []byte(`
110
{
111
  "jsonapi": {
112
    "version": "1.0"
113
  },
114
  "links": {
115
    "self": "https://api.lemonsqueezy.com/v1/webhooks/1"
116
  },
117
  "data": {
118
    "type": "webhooks",
119
    "id": "1",
120
    "attributes": {
121
      "store_id": 1,
122
      "url": "https://mysite.com/webhooks/",
123
      "events": [
124
        "order_created",
125
        "order_refunded",
126
        "subscription_created",
127
        "subscription_updated",
128
        "subscription_expired"
129
      ],
130
      "last_sent_at": "2022-11-22T07:38:06.000000Z",
131
      "created_at": "2022-06-07T08:32:47.000000Z",
132
      "updated_at": "2022-06-07T08:41:37.000000Z",
133
      "test_mode": false
134
    },
135
    "relationships": {
136
      "store": {
137
        "links": {
138
          "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store",
139
          "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store"
140
        }
141
      }
142
    },
143
    "links": {
144
      "self": "https://api.lemonsqueezy.com/v1/webhooks/1"
145
    }
146
  }
147
}
148
`)
149
}
150
151
// WebhooksListResponse is a dummy response to GET /v1/webhooks
152
func WebhooksListResponse() []byte {
153
	return []byte(`
154
{
155
  "meta": {
156
    "page": {
157
      "currentPage": 1,
158
      "from": 1,
159
      "lastPage": 1,
160
      "perPage": 10,
161
      "to": 10,
162
      "total": 10
163
    }
164
  },
165
  "jsonapi": {
166
    "version": "1.0"
167
  },
168
  "links": {
169
    "first": "https://api.lemonsqueezy.com/v1/webhooks?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt",
170
    "last": "https://api.lemonsqueezy.com/v1/webhooks?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt"
171
  },
172
  "data": [
173
    {
174
      "type": "webhooks",
175
      "id": "1",
176
      "attributes": {
177
      	"store_id": 1,
178
        "url": "https://mysite.com/webhooks/",
179
        "events": [
180
          "order_created",
181
          "subscription_created",
182
          "subscription_updated",
183
          "subscription_expired"
184
        ],
185
        "last_sent_at": "2022-11-22T07:38:06.000000Z",
186
        "created_at": "2022-06-07T08:32:47.000000Z",
187
        "updated_at": "2022-06-07T08:41:37.000000Z",
188
        "test_mode": false
189
      },
190
      "relationships": {
191
        "store": {
192
          "links": {
193
            "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store",
194
            "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store"
195
          }
196
        }
197
      },
198
      "links": {
199
        "self": "https://api.lemonsqueezy.com/v1/webhooks/1"
200
      }
201
    }
202
  ]
203
}
204
`)
205
}
206