Passed
Push — main ( 6599d2...81bd35 )
by Acho
01:34
created

internal/stubs/discount.go   A

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A stubs.DiscountsListResponse 0 2 1
A stubs.DiscountGetResponse 0 2 1
1
package stubs
2
3
// DiscountGetResponse is a dummy response to the GET /v1/discounts/:id endpoint
4
func DiscountGetResponse() []byte {
5
	return []byte(`
6
{
7
  "jsonapi": {
8
    "version": "1.0"
9
  },
10
  "links": {
11
    "self": "https://api.lemonsqueezy.com/v1/discounts/1"
12
  },
13
  "data": {
14
    "type": "discounts",
15
    "id": "1",
16
    "attributes": {
17
      "store_id": 1,
18
      "name": "10% Off",
19
      "code": "10PERCENT",
20
      "amount": 10,
21
      "amount_type": "percent",
22
      "is_limited_to_products": false,
23
      "is_limited_redemptions": false,
24
      "max_redemptions": 0,
25
      "starts_at": null,
26
      "expires_at": null,
27
      "duration": "once",
28
      "duration_in_months": 1,
29
      "status": "published",
30
      "status_formatted": "Published",
31
      "created_at": "2021-05-24T14:15:06.000000Z",
32
      "updated_at": "2021-05-24T14:15:06.000000Z"
33
    },
34
    "relationships": {
35
      "store": {
36
        "links": {
37
          "related": "https://api.lemonsqueezy.com/v1/discounts/1/store",
38
          "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/store"
39
        }
40
      },
41
      "variants": {
42
        "links": {
43
          "related": "https://api.lemonsqueezy.com/v1/discounts/1/variants",
44
          "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/variants"
45
        }
46
      },
47
      "discount-redemptions": {
48
        "links": {
49
          "related": "https://api.lemonsqueezy.com/v1/discounts/1/discount-redemptions",
50
          "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/discount-redemptions"
51
        }
52
      }
53
    },
54
    "links": {
55
      "self": "https://api.lemonsqueezy.com/v1/discounts/1"
56
    }
57
  }
58
}
59
`)
60
}
61
62
// DiscountsListResponse is a dummy response to GET /v1/discounts
63
func DiscountsListResponse() []byte {
64
	return []byte(`
65
{
66
  "meta": {
67
    "page": {
68
      "currentPage": 1,
69
      "from": 1,
70
      "lastPage": 1,
71
      "perPage": 10,
72
      "to": 10,
73
      "total": 10
74
    }
75
  },
76
  "jsonapi": {
77
    "version": "1.0"
78
  },
79
  "links": {
80
    "first": "https://api.lemonsqueezy.com/v1/discounts?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt",
81
    "last": "https://api.lemonsqueezy.com/v1/discounts?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt"
82
  },
83
  "data": [
84
    {
85
      "type": "discounts",
86
      "id": "1",
87
      "attributes": {
88
        "store_id": 1,
89
        "name": "10%",
90
        "code": "10PERC",
91
        "amount": 10,
92
        "amount_type": "percent",
93
        "is_limited_to_products": false,
94
        "is_limited_redemptions": false,
95
        "max_redemptions": 0,
96
        "starts_at": null,
97
        "expires_at": null,
98
        "duration": "once",
99
        "duration_in_months": 1,
100
        "status": "published",
101
        "status_formatted": "Published",
102
        "created_at": "2021-05-24T14:15:06.000000Z",
103
        "updated_at": "2021-05-24T14:15:06.000000Z"
104
      },
105
      "relationships": {
106
        "store": {
107
          "links": {
108
            "related": "https://api.lemonsqueezy.com/v1/discounts/1/store",
109
            "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/store"
110
          }
111
        },
112
        "variants": {
113
          "links": {
114
            "related": "https://api.lemonsqueezy.com/v1/discounts/1/variants",
115
            "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/variants"
116
          }
117
        },
118
        "discount-redemptions": {
119
          "links": {
120
            "related": "https://api.lemonsqueezy.com/v1/discounts/1/discount-redemptions",
121
            "self": "https://api.lemonsqueezy.com/v1/discounts/1/relationships/discount-redemptions"
122
          }
123
        }
124
      },
125
      "links": {
126
        "self": "https://api.lemonsqueezy.com/v1/discounts/1"
127
      }
128
    }
129
  ]
130
}
131
`)
132
}
133