Returns a list of your coupons.
curl https://api.stripe.com/v1/coupons?limit=3 \
-u STRIPE_SECRET_KEY: \
-G
func chilkatTest() {
let rest = CkoRest()
var success: Bool
// URL: https://api.stripe.com/v1/coupons?limit=3
var bTls: Bool = true
var port: Int = 443
var bAutoReconnect: Bool = true
success = rest.Connect("api.stripe.com", port: port, tls: bTls, autoReconnect: bAutoReconnect)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.integerValue)")
print("\(rest.LastErrorText)")
return
}
rest.SetAuthBasic("STRIPE_SECRET_KEY", password: "")
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestNoBodySb("GET", uriPath: "/v1/coupons?limit=3", sb: sbResponseBody)
if success != true {
print("\(rest.LastErrorText)")
return
}
let jsonResponse = CkoJsonObject()
jsonResponse.LoadSb(sbResponseBody)
var object: String?
var url: String?
var has_more: Bool
var i: Int
var count_i: Int
var id: String?
var amount_off: Bool
var created: Int
var currency: Bool
var duration: String?
var duration_in_months: Int
var livemode: Bool
var max_redemptions: Bool
var percent_off: Int
var redeem_by: Bool
var times_redeemed: Int
var valid: Bool
object = jsonResponse.StringOf("object")
url = jsonResponse.StringOf("url")
has_more = jsonResponse.BoolOf("has_more")
i = 0
count_i = jsonResponse.SizeOfArray("data").integerValue
while i < count_i {
jsonResponse.I = i
id = jsonResponse.StringOf("data[i].id")
object = jsonResponse.StringOf("data[i].object")
amount_off = jsonResponse.IsNullOf("data[i].amount_off")
created = jsonResponse.IntOf("data[i].created").integerValue
currency = jsonResponse.IsNullOf("data[i].currency")
duration = jsonResponse.StringOf("data[i].duration")
duration_in_months = jsonResponse.IntOf("data[i].duration_in_months").integerValue
livemode = jsonResponse.BoolOf("data[i].livemode")
max_redemptions = jsonResponse.IsNullOf("data[i].max_redemptions")
percent_off = jsonResponse.IntOf("data[i].percent_off").integerValue
redeem_by = jsonResponse.IsNullOf("data[i].redeem_by")
times_redeemed = jsonResponse.IntOf("data[i].times_redeemed").integerValue
valid = jsonResponse.BoolOf("data[i].valid")
i = i + 1
}
}
{
"object": "list",
"url": "/v1/coupons",
"has_more": false,
"data": [
{
"id": "25OFF",
"object": "coupon",
"amount_off": null,
"created": 1516662783,
"currency": null,
"duration": "repeating",
"duration_in_months": 3,
"livemode": false,
"max_redemptions": null,
"metadata": {},
"percent_off": 25,
"redeem_by": null,
"times_redeemed": 0,
"valid": true
}
]
}