sfgboxapi

<back to all web services

CreateSubscribeCustomer

Requires Authentication
The following routes are available for this service:
POST/create-customer
import 'package:servicestack/servicestack.dart';

enum StripeType
{
    unknown,
    account,
    card,
    charge,
    coupon,
    customer,
    discount,
    dispute,
    event,
    invoiceitem,
    invoice,
    line_item,
    plan,
    subscription,
    token,
    transfer,
    list,
    product,
}

class StripeObject implements IConvertible
{
    StripeType? object;

    StripeObject({this.object});
    StripeObject.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        object = JsonConverters.fromJson(json['object'],'StripeType',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'object': JsonConverters.toJson(object,'StripeType',context!)
    };

    getTypeName() => "StripeObject";
    TypeContext? context = _ctx;
}

class StripeId extends StripeObject implements IConvertible
{
    String? id;

    StripeId({this.id});
    StripeId.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        id = json['id'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'id': id
    });

    getTypeName() => "StripeId";
    TypeContext? context = _ctx;
}

enum StripeCouponDuration
{
    forever,
    once,
    repeating,
}

class StripeCoupon extends StripeId implements IConvertible
{
    int? amountOff;
    DateTime? created;
    String? currency;
    StripeCouponDuration? duration;
    int? durationInMonths;
    bool? livemode;
    int? maxRedemptions;
    Map<String,String?>? metadata;
    int? percentOff;
    DateTime? redeemBy;
    int? timesRedeemed;
    bool? valid;

    StripeCoupon({this.amountOff,this.created,this.currency,this.duration,this.durationInMonths,this.livemode,this.maxRedemptions,this.metadata,this.percentOff,this.redeemBy,this.timesRedeemed,this.valid});
    StripeCoupon.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        amountOff = json['amountOff'];
        created = JsonConverters.fromJson(json['created'],'DateTime',context!);
        currency = json['currency'];
        duration = JsonConverters.fromJson(json['duration'],'StripeCouponDuration',context!);
        durationInMonths = json['durationInMonths'];
        livemode = json['livemode'];
        maxRedemptions = json['maxRedemptions'];
        metadata = JsonConverters.toStringMap(json['metadata']);
        percentOff = json['percentOff'];
        redeemBy = JsonConverters.fromJson(json['redeemBy'],'DateTime',context!);
        timesRedeemed = json['timesRedeemed'];
        valid = json['valid'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'amountOff': amountOff,
        'created': JsonConverters.toJson(created,'DateTime',context!),
        'currency': currency,
        'duration': JsonConverters.toJson(duration,'StripeCouponDuration',context!),
        'durationInMonths': durationInMonths,
        'livemode': livemode,
        'maxRedemptions': maxRedemptions,
        'metadata': metadata,
        'percentOff': percentOff,
        'redeemBy': JsonConverters.toJson(redeemBy,'DateTime',context!),
        'timesRedeemed': timesRedeemed,
        'valid': valid
    });

    getTypeName() => "StripeCoupon";
    TypeContext? context = _ctx;
}

class StripeDiscount extends StripeId implements IConvertible
{
    String? customer;
    StripeCoupon? coupon;
    DateTime? start;
    DateTime? end;

    StripeDiscount({this.customer,this.coupon,this.start,this.end});
    StripeDiscount.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        customer = json['customer'];
        coupon = JsonConverters.fromJson(json['coupon'],'StripeCoupon',context!);
        start = JsonConverters.fromJson(json['start'],'DateTime',context!);
        end = JsonConverters.fromJson(json['end'],'DateTime',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'customer': customer,
        'coupon': JsonConverters.toJson(coupon,'StripeCoupon',context!),
        'start': JsonConverters.toJson(start,'DateTime',context!),
        'end': JsonConverters.toJson(end,'DateTime',context!)
    });

    getTypeName() => "StripeDiscount";
    TypeContext? context = _ctx;
}

class StripeAddress implements IConvertible
{
    String? city;
    String? country;
    String? line1;
    String? line2;
    String? postalCode;
    String? state;

    StripeAddress({this.city,this.country,this.line1,this.line2,this.postalCode,this.state});
    StripeAddress.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        city = json['city'];
        country = json['country'];
        line1 = json['line1'];
        line2 = json['line2'];
        postalCode = json['postalCode'];
        state = json['state'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'city': city,
        'country': country,
        'line1': line1,
        'line2': line2,
        'postalCode': postalCode,
        'state': state
    };

    getTypeName() => "StripeAddress";
    TypeContext? context = _ctx;
}

class StripeShipping implements IConvertible
{
    StripeAddress? address;
    String? name;
    String? phone;

    StripeShipping({this.address,this.name,this.phone});
    StripeShipping.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        address = JsonConverters.fromJson(json['address'],'StripeAddress',context!);
        name = json['name'];
        phone = json['phone'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'address': JsonConverters.toJson(address,'StripeAddress',context!),
        'name': name,
        'phone': phone
    };

    getTypeName() => "StripeShipping";
    TypeContext? context = _ctx;
}

enum StripeCvcCheck
{
    Unknown,
    Pass,
    Fail,
    Unchecked,
}

class StripeCard extends StripeId implements IConvertible
{
    String? brand;
    String? number;
    String? last4;
    String? dynamicLast4;
    int? expMonth;
    int? expYear;
    String? cvc;
    String? name;
    String? addressCity;
    String? addressCountry;
    String? addressLine1;
    String? addressLine2;
    String? addressState;
    String? addressZip;
    StripeCvcCheck? cvcCheck;
    String? addressLine1Check;
    String? addressZipCheck;
    String? funding;
    String? fingerprint;
    String? customer;
    String? country;

    StripeCard({this.brand,this.number,this.last4,this.dynamicLast4,this.expMonth,this.expYear,this.cvc,this.name,this.addressCity,this.addressCountry,this.addressLine1,this.addressLine2,this.addressState,this.addressZip,this.cvcCheck,this.addressLine1Check,this.addressZipCheck,this.funding,this.fingerprint,this.customer,this.country});
    StripeCard.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        brand = json['brand'];
        number = json['number'];
        last4 = json['last4'];
        dynamicLast4 = json['dynamicLast4'];
        expMonth = json['expMonth'];
        expYear = json['expYear'];
        cvc = json['cvc'];
        name = json['name'];
        addressCity = json['addressCity'];
        addressCountry = json['addressCountry'];
        addressLine1 = json['addressLine1'];
        addressLine2 = json['addressLine2'];
        addressState = json['addressState'];
        addressZip = json['addressZip'];
        cvcCheck = JsonConverters.fromJson(json['cvcCheck'],'StripeCvcCheck',context!);
        addressLine1Check = json['addressLine1Check'];
        addressZipCheck = json['addressZipCheck'];
        funding = json['funding'];
        fingerprint = json['fingerprint'];
        customer = json['customer'];
        country = json['country'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'brand': brand,
        'number': number,
        'last4': last4,
        'dynamicLast4': dynamicLast4,
        'expMonth': expMonth,
        'expYear': expYear,
        'cvc': cvc,
        'name': name,
        'addressCity': addressCity,
        'addressCountry': addressCountry,
        'addressLine1': addressLine1,
        'addressLine2': addressLine2,
        'addressState': addressState,
        'addressZip': addressZip,
        'cvcCheck': JsonConverters.toJson(cvcCheck,'StripeCvcCheck',context!),
        'addressLine1Check': addressLine1Check,
        'addressZipCheck': addressZipCheck,
        'funding': funding,
        'fingerprint': fingerprint,
        'customer': customer,
        'country': country
    });

    getTypeName() => "StripeCard";
    TypeContext? context = _ctx;
}

enum StripeSubscriptionStatus
{
    Unknown,
    Trialing,
    Active,
    PastDue,
    Canceled,
    Unpaid,
}

enum StripePlanInterval
{
    month,
    year,
}

class StripePlan extends StripeId implements IConvertible
{
    int? amount;
    DateTime? created;
    String? currency;
    StripePlanInterval? interval;
    int? intervalCount;
    bool? livemode;
    Map<String,String?>? metadata;
    String? nickname;
    String? product;
    int? trialPeriodDays;

    StripePlan({this.amount,this.created,this.currency,this.interval,this.intervalCount,this.livemode,this.metadata,this.nickname,this.product,this.trialPeriodDays});
    StripePlan.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        amount = json['amount'];
        created = JsonConverters.fromJson(json['created'],'DateTime',context!);
        currency = json['currency'];
        interval = JsonConverters.fromJson(json['interval'],'StripePlanInterval',context!);
        intervalCount = json['intervalCount'];
        livemode = json['livemode'];
        metadata = JsonConverters.toStringMap(json['metadata']);
        nickname = json['nickname'];
        product = json['product'];
        trialPeriodDays = json['trialPeriodDays'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'amount': amount,
        'created': JsonConverters.toJson(created,'DateTime',context!),
        'currency': currency,
        'interval': JsonConverters.toJson(interval,'StripePlanInterval',context!),
        'intervalCount': intervalCount,
        'livemode': livemode,
        'metadata': metadata,
        'nickname': nickname,
        'product': product,
        'trialPeriodDays': trialPeriodDays
    });

    getTypeName() => "StripePlan";
    TypeContext? context = _ctx;
}

class StripeSubscription extends StripeId implements IConvertible
{
    DateTime? currentPeriodEnd;
    StripeSubscriptionStatus? status;
    StripePlan? plan;
    DateTime? currentPeriodStart;
    DateTime? start;
    DateTime? trialStart;
    bool? cancelAtPeriodEnd;
    DateTime? trialEnd;
    DateTime? canceledAt;
    DateTime? endedAt;
    String? customer;
    int? quantity;

    StripeSubscription({this.currentPeriodEnd,this.status,this.plan,this.currentPeriodStart,this.start,this.trialStart,this.cancelAtPeriodEnd,this.trialEnd,this.canceledAt,this.endedAt,this.customer,this.quantity});
    StripeSubscription.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        currentPeriodEnd = JsonConverters.fromJson(json['currentPeriodEnd'],'DateTime',context!);
        status = JsonConverters.fromJson(json['status'],'StripeSubscriptionStatus',context!);
        plan = JsonConverters.fromJson(json['plan'],'StripePlan',context!);
        currentPeriodStart = JsonConverters.fromJson(json['currentPeriodStart'],'DateTime',context!);
        start = JsonConverters.fromJson(json['start'],'DateTime',context!);
        trialStart = JsonConverters.fromJson(json['trialStart'],'DateTime',context!);
        cancelAtPeriodEnd = json['cancelAtPeriodEnd'];
        trialEnd = JsonConverters.fromJson(json['trialEnd'],'DateTime',context!);
        canceledAt = JsonConverters.fromJson(json['canceledAt'],'DateTime',context!);
        endedAt = JsonConverters.fromJson(json['endedAt'],'DateTime',context!);
        customer = json['customer'];
        quantity = json['quantity'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'currentPeriodEnd': JsonConverters.toJson(currentPeriodEnd,'DateTime',context!),
        'status': JsonConverters.toJson(status,'StripeSubscriptionStatus',context!),
        'plan': JsonConverters.toJson(plan,'StripePlan',context!),
        'currentPeriodStart': JsonConverters.toJson(currentPeriodStart,'DateTime',context!),
        'start': JsonConverters.toJson(start,'DateTime',context!),
        'trialStart': JsonConverters.toJson(trialStart,'DateTime',context!),
        'cancelAtPeriodEnd': cancelAtPeriodEnd,
        'trialEnd': JsonConverters.toJson(trialEnd,'DateTime',context!),
        'canceledAt': JsonConverters.toJson(canceledAt,'DateTime',context!),
        'endedAt': JsonConverters.toJson(endedAt,'DateTime',context!),
        'customer': customer,
        'quantity': quantity
    });

    getTypeName() => "StripeSubscription";
    TypeContext? context = _ctx;
}

class StripeCustomer extends StripeId implements IConvertible
{
    int? accountBalance;
    String? businessVatId;
    DateTime? created;
    String? defaultSource;
    bool? delinquent;
    String? description;
    StripeDiscount? discount;
    String? email;
    String? invoicePrefix;
    bool? livemode;
    Map<String,String?>? metadata;
    StripeShipping? shipping;
    StripeCollection<StripeCard>? sources;
    StripeCollection<StripeSubscription>? subscriptions;
    bool? deleted;
    String? currency;

    StripeCustomer({this.accountBalance,this.businessVatId,this.created,this.defaultSource,this.delinquent,this.description,this.discount,this.email,this.invoicePrefix,this.livemode,this.metadata,this.shipping,this.sources,this.subscriptions,this.deleted,this.currency});
    StripeCustomer.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        accountBalance = json['accountBalance'];
        businessVatId = json['businessVatId'];
        created = JsonConverters.fromJson(json['created'],'DateTime',context!);
        defaultSource = json['defaultSource'];
        delinquent = json['delinquent'];
        description = json['description'];
        discount = JsonConverters.fromJson(json['discount'],'StripeDiscount',context!);
        email = json['email'];
        invoicePrefix = json['invoicePrefix'];
        livemode = json['livemode'];
        metadata = JsonConverters.toStringMap(json['metadata']);
        shipping = JsonConverters.fromJson(json['shipping'],'StripeShipping',context!);
        sources = JsonConverters.fromJson(json['sources'],'StripeCollection<StripeCard>',context!);
        subscriptions = JsonConverters.fromJson(json['subscriptions'],'StripeCollection<StripeSubscription>',context!);
        deleted = json['deleted'];
        currency = json['currency'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'accountBalance': accountBalance,
        'businessVatId': businessVatId,
        'created': JsonConverters.toJson(created,'DateTime',context!),
        'defaultSource': defaultSource,
        'delinquent': delinquent,
        'description': description,
        'discount': JsonConverters.toJson(discount,'StripeDiscount',context!),
        'email': email,
        'invoicePrefix': invoicePrefix,
        'livemode': livemode,
        'metadata': metadata,
        'shipping': JsonConverters.toJson(shipping,'StripeShipping',context!),
        'sources': JsonConverters.toJson(sources,'StripeCollection<StripeCard>',context!),
        'subscriptions': JsonConverters.toJson(subscriptions,'StripeCollection<StripeSubscription>',context!),
        'deleted': deleted,
        'currency': currency
    });

    getTypeName() => "StripeCustomer";
    TypeContext? context = _ctx;
}

class CreateSubscribeCustomer implements IPost, IConvertible
{
    String? email;

    CreateSubscribeCustomer({this.email});
    CreateSubscribeCustomer.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        email = json['email'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'email': email
    };

    getTypeName() => "CreateSubscribeCustomer";
    TypeContext? context = _ctx;
}

class StripeCollection<T> extends StripeId implements IConvertible
{
    String? url;
    int? totalCount;
    bool? hasMore;
    List<T>? data;

    StripeCollection({this.url,this.totalCount,this.hasMore,this.data});
    StripeCollection.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        url = json['url'];
        totalCount = json['totalCount'];
        hasMore = json['hasMore'];
        data = JsonConverters.fromJson(json['data'],'List<${runtimeGenericTypeDefs(this,[0]).join(",")}>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'url': url,
        'totalCount': totalCount,
        'hasMore': hasMore,
        'data': JsonConverters.toJson(data,'List<T>',context!)
    });

    getTypeName() => "StripeCollection<$T>";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.sfgtec.com', types: <String, TypeInfo> {
    'StripeType': TypeInfo(TypeOf.Enum, enumValues:StripeType.values),
    'StripeObject': TypeInfo(TypeOf.Class, create:() => StripeObject()),
    'StripeId': TypeInfo(TypeOf.Class, create:() => StripeId()),
    'StripeCouponDuration': TypeInfo(TypeOf.Enum, enumValues:StripeCouponDuration.values),
    'StripeCoupon': TypeInfo(TypeOf.Class, create:() => StripeCoupon()),
    'StripeDiscount': TypeInfo(TypeOf.Class, create:() => StripeDiscount()),
    'StripeAddress': TypeInfo(TypeOf.Class, create:() => StripeAddress()),
    'StripeShipping': TypeInfo(TypeOf.Class, create:() => StripeShipping()),
    'StripeCvcCheck': TypeInfo(TypeOf.Enum, enumValues:StripeCvcCheck.values),
    'StripeCard': TypeInfo(TypeOf.Class, create:() => StripeCard()),
    'StripeSubscriptionStatus': TypeInfo(TypeOf.Enum, enumValues:StripeSubscriptionStatus.values),
    'StripePlanInterval': TypeInfo(TypeOf.Enum, enumValues:StripePlanInterval.values),
    'StripePlan': TypeInfo(TypeOf.Class, create:() => StripePlan()),
    'StripeSubscription': TypeInfo(TypeOf.Class, create:() => StripeSubscription()),
    'StripeCustomer': TypeInfo(TypeOf.Class, create:() => StripeCustomer()),
    'StripeCollection<StripeCard>': TypeInfo(TypeOf.Class, create:() => StripeCollection<StripeCard>()),
    'StripeCollection<StripeSubscription>': TypeInfo(TypeOf.Class, create:() => StripeCollection<StripeSubscription>()),
    'CreateSubscribeCustomer': TypeInfo(TypeOf.Class, create:() => CreateSubscribeCustomer()),
    'StripeCollection<T>': TypeInfo(TypeOf.Class, create:() => StripeCollection<T>()),
});

Dart CreateSubscribeCustomer DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /create-customer HTTP/1.1 
Host: api.sfgtec.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"email":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"accountBalance":0,"businessVatId":"String","created":"\/Date(-62135596800000-0000)\/","defaultSource":"String","delinquent":false,"description":"String","discount":{"customer":"String","coupon":{"amountOff":0,"created":"\/Date(-62135596800000-0000)\/","currency":"String","duration":"forever","durationInMonths":0,"livemode":false,"maxRedemptions":0,"metadata":{"String":"String"},"percentOff":0,"redeemBy":"\/Date(-62135596800000-0000)\/","timesRedeemed":0,"valid":false,"id":"String","object":"unknown"},"start":"\/Date(-62135596800000-0000)\/","end":"\/Date(-62135596800000-0000)\/","id":"String","object":"unknown"},"email":"String","invoicePrefix":"String","livemode":false,"metadata":{"String":"String"},"shipping":{"address":{"city":"String","country":"String","line1":"String","line2":"String","postalCode":"String","state":"String"},"name":"String","phone":"String"},"sources":{"url":"String","totalCount":0,"hasMore":false,"data":[{"brand":"String","number":"String","last4":"String","dynamicLast4":"String","expMonth":0,"expYear":0,"cvc":"String","name":"String","addressCity":"String","addressCountry":"String","addressLine1":"String","addressLine2":"String","addressState":"String","addressZip":"String","cvcCheck":"Unknown","addressLine1Check":"String","addressZipCheck":"String","funding":"String","fingerprint":"String","customer":"String","country":"String","id":"String","object":"unknown"}],"id":"String","object":"unknown"},"subscriptions":{"url":"String","totalCount":0,"hasMore":false,"data":[{"currentPeriodEnd":"\/Date(-62135596800000-0000)\/","status":"Unknown","plan":{"amount":0,"created":"\/Date(-62135596800000-0000)\/","currency":"String","interval":"month","intervalCount":0,"livemode":false,"metadata":{"String":"String"},"nickname":"String","product":"String","trialPeriodDays":0,"id":"String","object":"unknown"},"currentPeriodStart":"\/Date(-62135596800000-0000)\/","start":"\/Date(-62135596800000-0000)\/","trialStart":"\/Date(-62135596800000-0000)\/","cancelAtPeriodEnd":false,"trialEnd":"\/Date(-62135596800000-0000)\/","canceledAt":"\/Date(-62135596800000-0000)\/","endedAt":"\/Date(-62135596800000-0000)\/","customer":"String","quantity":0,"id":"String","object":"unknown"}],"id":"String","object":"unknown"},"deleted":false,"currency":"String","id":"String","object":"unknown"}