internal/stubs/order.go   A
last analyzed

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
dl 0
loc 110
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stubs.OrderGetResponse 0 2 1
A stubs.OrdersListResponse 0 2 1
1
package stubs
2
3
// OrderGetResponse is a dummy response to the GET /v1/orders/:id endpoint
4
func OrderGetResponse() []byte {
5
	return []byte(`
6
{
7
  "jsonapi": {
8
    "version": "1.0"
9
  },
10
  "links": {
11
    "self": "https://api.lemonsqueezy.com/v1/orders/1"
12
  },
13
  "data": {
14
    "type": "orders",
15
    "id": "1",
16
    "attributes": {
17
      "store_id": 1,
18
      "customer_id": 1,
19
      "identifier": "104e18a2-d755-4d4b-80c4-a6c1dcbe1c10",
20
      "order_number": 1,
21
      "user_name": "Darlene Daugherty",
22
      "user_email": "[email protected]",
23
      "currency": "USD",
24
      "currency_rate": "1.0000",
25
      "subtotal": 999,
26
      "discount_total": 0,
27
      "tax": 200,
28
      "total": 1199,
29
      "subtotal_usd": 999,
30
      "discount_total_usd": 0,
31
      "tax_usd": 200,
32
      "total_usd": 1199,
33
      "tax_name": "VAT",
34
      "tax_rate": "20.00",
35
      "status": "paid",
36
      "status_formatted": "Paid",
37
      "refunded": false,
38
      "refunded_at": null,
39
      "subtotal_formatted": "$9.99",
40
      "discount_total_formatted": "$0.00",
41
      "tax_formatted": "$2.00",
42
      "total_formatted": "$11.99",
43
      "first_order_item": {
44
        "id": 1,
45
        "order_id": 1,
46
        "product_id": 1,
47
        "variant_id": 1,
48
        "product_name": "Test Limited Licencse for 2 years",
49
        "variant_name": "Default",
50
        "price": 1199,
51
        "created_at": "2021-08-17T09:45:53.000000Z",
52
        "updated_at": "2021-08-17T09:45:53.000000Z",
53
        "deleted_at": null,
54
        "test_mode": false
55
      },
56
      "urls": {
57
        "receipt": "https://app.lemonsqueezy.com/my-orders/104e18a2-d755-4d4b-80c4-a6c1dcbe1c10?signature=8847fff02e1bfb0c7c43ff1cdf1b1657a8eed2029413692663b86859208c9f42"
58
      },
59
      "created_at": "2021-08-17T09:45:53.000000Z",
60
      "updated_at": "2021-08-17T09:45:53.000000Z"
61
    },
62
    "relationships": {
63
      "store": {
64
        "links": {
65
          "related": "https://api.lemonsqueezy.com/v1/orders/1/store",
66
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/store"
67
        }
68
      },
69
      "customer": {
70
        "links": {
71
          "related": "https://api.lemonsqueezy.com/v1/orders/1/customer",
72
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/customer"
73
        }
74
      },
75
      "order-items": {
76
        "links": {
77
          "related": "https://api.lemonsqueezy.com/v1/orders/1/order-items",
78
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/order-items"
79
        }
80
      },
81
      "subscriptions": {
82
        "links": {
83
          "related": "https://api.lemonsqueezy.com/v1/orders/1/subscriptions",
84
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/subscriptions"
85
        }
86
      },
87
      "license-keys": {
88
        "links": {
89
          "related": "https://api.lemonsqueezy.com/v1/orders/1/license-keys",
90
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/license-keys"
91
        }
92
      },
93
      "discount-redemptions": {
94
        "links": {
95
          "related": "https://api.lemonsqueezy.com/v1/orders/1/discount-redemptions",
96
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/discount-redemptions"
97
        }
98
      }
99
    },
100
    "links": {
101
      "self": "https://api.lemonsqueezy.com/v1/orders/1"
102
    }
103
  }
104
}
105
`)
106
}
107
108
// OrdersListResponse is a dummy response to GET /v1/orders
109
func OrdersListResponse() []byte {
110
	return []byte(`
111
{
112
  "meta": {
113
    "page": {
114
      "currentPage": 1,
115
      "from": 1,
116
      "lastPage": 1,
117
      "perPage": 10,
118
      "to": 10,
119
      "total": 10
120
    }
121
  },
122
  "jsonapi": {
123
    "version": "1.0"
124
  },
125
  "links": {
126
    "first": "https://api.lemonsqueezy.com/v1/orders?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=-createdAt",
127
    "last": "https://api.lemonsqueezy.com/v1/orders?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=-createdAt"
128
  },
129
  "data": [
130
    {
131
      "type": "orders",
132
      "id": "1",
133
      "attributes": {
134
        "store_id": 1,
135
        "customer_id": 1,
136
        "identifier": "104e18a2-d755-4d4b-80c4-a6c1dcbe1c10",
137
        "order_number": 1,
138
        "user_name": "Darlene Daugherty",
139
        "user_email": "[email protected]",
140
        "currency": "USD",
141
        "currency_rate": "1.0000",
142
        "subtotal": 999,
143
        "discount_total": 0,
144
        "tax": 200,
145
        "total": 1199,
146
        "subtotal_usd": 999,
147
        "discount_total_usd": 0,
148
        "tax_usd": 200,
149
        "total_usd": 1199,
150
        "tax_name": "VAT",
151
        "tax_rate": "20.00",
152
        "status": "paid",
153
        "status_formatted": "Paid",
154
        "refunded": false,
155
        "refunded_at": null,
156
        "subtotal_formatted": "$9.99",
157
        "discount_total_formatted": "$0.00",
158
        "tax_formatted": "$2.00",
159
        "total_formatted": "$11.99",
160
        "first_order_item": {
161
          "id": 1,
162
          "order_id": 1,
163
          "product_id": 1,
164
          "variant_id": 1,
165
          "product_name": "Test Limited Licencse for 2 years",
166
          "variant_name": "Default",
167
          "price": 1199,
168
          "created_at": "2021-08-17T09:45:53.000000Z",
169
          "updated_at": "2021-08-17T09:45:53.000000Z",
170
          "deleted_at": null,
171
          "test_mode": false
172
        },
173
        "urls": {
174
          "receipt": "https://app.lemonsqueezy.com/my-orders/104e18a2-d755-4d4b-80c4-a6c1dcbe1c10?signature=8847fff02e1bfb0c7c43ff1cdf1b1657a8eed2029413692663b86859208c9f42"
175
        },
176
        "created_at": "2021-08-17T09:45:53.000000Z",
177
        "updated_at": "2021-08-17T09:45:53.000000Z"
178
      },
179
      "relationships": {
180
        "store": {
181
          "links": {
182
            "related": "https://api.lemonsqueezy.com/v1/orders/1/store",
183
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/store"
184
          }
185
        },
186
        "customer": {
187
          "links": {
188
            "related": "https://api.lemonsqueezy.com/v1/orders/1/customer",
189
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/customer"
190
          }
191
        },
192
        "order-items": {
193
          "links": {
194
            "related": "https://api.lemonsqueezy.com/v1/orders/1/order-items",
195
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/order-items"
196
          }
197
        },
198
        "subscriptions": {
199
          "links": {
200
            "related": "https://api.lemonsqueezy.com/v1/orders/1/subscriptions",
201
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/subscriptions"
202
          }
203
        },
204
        "license-keys": {
205
          "links": {
206
            "related": "https://api.lemonsqueezy.com/v1/orders/1/license-keys",
207
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/license-keys"
208
          }
209
        },
210
        "discount-redemptions": {
211
          "links": {
212
            "related": "https://api.lemonsqueezy.com/v1/orders/1/discount-redemptions",
213
            "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/discount-redemptions"
214
          }
215
        }
216
      },
217
      "links": {
218
        "self": "https://api.lemonsqueezy.com/v1/orders/1"
219
      }
220
    }
221
  ]
222
}
223
`)
224
}
225