Passed
Push — main ( 4ea244...5e41d5 )
by Acho
01:33 queued 13s
created

internal/stubs/order.go   A

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

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