STPCustomerDeserializer

public class STPCustomerDeserializer : NSObject

Use STPCustomerDeserializer to convert a response from the Stripe API into an STPCustomer object. STPCustomerDeserializer expects the JSON response to be in the exact same format as the Stripe API.

  • If a customer was successfully parsed from the response, it will be set here. Otherwise, this value wil be nil (and the error property will explain what went wrong).

    Declaration

    Swift

    @objc
    public let customer: STPCustomer?
  • If the deserializer failed to parse a customer, this property will explain why (and the customer property will be nil).

    Declaration

    Swift

    @objc
    public let error: Error?
  • Initialize a customer deserializer. The data, urlResponse, and error parameters are intended to be passed from an NSURLSessionDataTask callback. After it has been initialized, you can inspect the error and customer properties to see if the deserialization was successful. If error is nil, customer will be non-nil (and vice versa).

    Declaration

    Swift

    @objc
    public convenience init(
      data: Data?,
      urlResponse: URLResponse?,
      error: Error?
    )

    Parameters

    data

    An NSData object representing encoded JSON for a Customer object

    urlResponse

    The URL response obtained from the NSURLSessionTask

    error

    Any error that occurred from the URL session task (if this is non-nil, the error property will be set to this value after initialization).

  • Initializes a customer deserializer with a JSON dictionary. This JSON should be in the exact same format as what the Stripe API returns. If it’s successfully parsed, the customer parameter will be present after initialization; otherwise error will be present.

    Declaration

    Swift

    @objc
    public convenience init(jsonResponse json: Any?)

    Parameters

    json

    a JSON dictionary.