internal/stubs/variant.go   A
last analyzed

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stubs.VariantGetResponse 0 2 1
A stubs.VariantsListResponse 0 2 1
1
package stubs
2
3
// VariantGetResponse is a dummy response to the GET /v1/variants/:id endpoint
4
func VariantGetResponse() []byte {
5
	return []byte(`
6
{
7
  "jsonapi": {
8
    "version": "1.0"
9
  },
10
  "links": {
11
    "self": "https://api.lemonsqueezy.com/v1/variants/1"
12
  },
13
  "data": {
14
    "type": "variants",
15
    "id": "1",
16
    "attributes": {
17
      "product_id": 1,
18
      "name": "Example Variant",
19
      "slug": "46beb127-a8a9-33e6-89b5-078505657239",
20
      "description": "<p>Lorem ipsum...</p>",
21
      "price": 999,
22
      "is_subscription": false,
23
      "interval": null,
24
      "interval_count": null,
25
      "has_free_trial": false,
26
      "trial_interval": "day",
27
      "trial_interval_count": 30,
28
      "pay_what_you_want": false,
29
      "min_price": 0,
30
      "suggested_price": 0,
31
      "has_license_keys": false,
32
      "license_activation_limit": 5,
33
      "is_license_limit_unlimited": false,
34
      "license_length_value": 1,
35
      "license_length_unit": "years",
36
      "is_license_length_unlimited": false,
37
      "sort": 1,
38
      "status": "published",
39
      "status_formatted": "Published",
40
      "created_at": "2021-05-24T14:15:06.000000Z",
41
      "updated_at": "2021-06-24T14:44:38.000000Z",
42
      "test_mode": false
43
    },
44
    "relationships": {
45
      "product": {
46
        "links": {
47
          "related": "https://api.lemonsqueezy.com/v1/variants/1/product",
48
          "self": "https://api.lemonsqueezy.com/v1/variants/1/relationships/product"
49
        }
50
      }
51
    },
52
    "links": {
53
      "self": "https://api.lemonsqueezy.com/v1/variants/1"
54
    }
55
  }
56
}
57
`)
58
}
59
60
// VariantsListResponse is a dummy response to GET /v1/variants
61
func VariantsListResponse() []byte {
62
	return []byte(`
63
{
64
  "meta": {
65
    "page": {
66
      "currentPage": 1,
67
      "from": 1,
68
      "lastPage": 1,
69
      "perPage": 10,
70
      "to": 10,
71
      "total": 10
72
    }
73
  },
74
  "jsonapi": {
75
    "version": "1.0"
76
  },
77
  "links": {
78
    "first": "https:\/\/api.lemonsqueezy.com\/v1\/variants?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=sort",
79
    "last": "https:\/\/api.lemonsqueezy.com\/v1\/variants?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=sort"
80
  },
81
  "data": [
82
    {
83
      "type": "variants",
84
      "id": "1",
85
      "attributes": {
86
        "product_id": 1,
87
        "name": "Example Variant",
88
        "slug": "46beb127-a8a9-33e6-89b5-078505657239",
89
        "description": "<p>Lorem ipsum...<\/p>",
90
        "price": 999,
91
        "is_subscription": false,
92
        "interval": null,
93
        "interval_count": null,
94
        "has_free_trial": false,
95
        "trial_interval": "day",
96
        "trial_interval_count": 30,
97
        "pay_what_you_want": false,
98
        "min_price": 0,
99
        "suggested_price": 0,
100
        "has_license_keys": false,
101
        "license_activation_limit": 5,
102
        "is_license_limit_unlimited": false,
103
        "license_length_value": 1,
104
        "license_length_unit": "years",
105
        "is_license_length_unlimited": false,
106
        "sort": 1,
107
        "status": "published",
108
        "status_formatted": "Published",
109
        "created_at": "2021-05-24T14:15:06.000000Z",
110
        "updated_at": "2021-06-24T14:44:38.000000Z",
111
        "test_mode": false
112
      },
113
      "relationships": {
114
        "product": {
115
          "links": {
116
            "related": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1\/product",
117
            "self": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1\/relationships\/product"
118
          }
119
        }
120
      },
121
      "links": {
122
        "self": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1"
123
      }
124
    },
125
	{
126
      "type": "variants",
127
      "id": "2",
128
      "attributes": {
129
        "product_id": 1,
130
        "name": "Example Variant",
131
        "slug": "46beb127-a8a9-33e6-89b5-078505657239",
132
        "description": "<p>Lorem ipsum...<\/p>",
133
        "price": 999,
134
        "is_subscription": false,
135
        "interval": null,
136
        "interval_count": null,
137
        "has_free_trial": false,
138
        "trial_interval": "day",
139
        "trial_interval_count": 30,
140
        "pay_what_you_want": false,
141
        "min_price": 0,
142
        "suggested_price": 0,
143
        "has_license_keys": false,
144
        "license_activation_limit": 5,
145
        "is_license_limit_unlimited": false,
146
        "license_length_value": 1,
147
        "license_length_unit": "years",
148
        "is_license_length_unlimited": false,
149
        "sort": 1,
150
        "status": "published",
151
        "status_formatted": "Published",
152
        "created_at": "2021-05-24T14:15:06.000000Z",
153
        "updated_at": "2021-06-24T14:44:38.000000Z",
154
        "test_mode": false
155
      },
156
      "relationships": {
157
        "product": {
158
          "links": {
159
            "related": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1\/product",
160
            "self": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1\/relationships\/product"
161
          }
162
        }
163
      },
164
      "links": {
165
        "self": "https:\/\/api.lemonsqueezy.com\/v1\/variants\/1"
166
      }
167
    }
168
  ]
169
}
170
`)
171
}
172