Skip to content

Instantly share code, notes, and snippets.

@mshick
Last active November 10, 2021 21:05
Show Gist options
  • Save mshick/70b8e92ea19307e138b53956c85b63a2 to your computer and use it in GitHub Desktop.
Save mshick/70b8e92ea19307e138b53956c85b63a2 to your computer and use it in GitHub Desktop.
openapi-updates

Single Customer

Makes use of path ops and path template.

{
  Stripe_getCustomersCustomer(customer: "cus_Jtvm4LSm8CA3Qf") {
    ... on Stripe_Customer {
      id
      name
      email
      description
    }
  }
}

Customer List

Makes use of searchParams.

{
  Stripe_getCustomers(email: "[email protected]") {
    data {
      id
      name
      email
      description
    }
  }
}

Update a customer

Makes use of expand, which has to be serialized according to params.

mutation {
  Stripe_postCustomersCustomer(
    customer: "cus_Jtvm4LSm8CA3Qf"
    input: { description: "lalala", expand: ["subscriptions"] }
  ) {
    id
    name
    email
    description
    subscriptions {
      data {
        id
        collection_method
      }
    }
  }
}
{
"projectId": "e8d018b6-1bba-477e-9c41-5633b6dd1edc",
"dataKey": "AQIDAHhcZWXOdlBglkxBhI23ElO/clC/kuw5ynjXDSqJgfTz8gHMEoqvJr+RQrFbZx9cKCsGAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMV5Q0aUtyBJJlqFpXAgEQgDsoVnqn7GZS4+YoBz2yALFbG8pnKUbgHRqL6G6yw63fy8CctGBfHpbjoE9hvZpXpEpoAtXmddK+bz5dfQ==",
"version": 4,
"created": "2021-11-10T19:31:19.769Z",
"updated": "2021-11-10T20:06:03.942Z",
"defaultLocale": "en-us",
"locales": ["en-us"],
"apiVersion": "2",
"schemaVersion": "3.9.0",
"queries": {
"Stripe_getCustomers": {
"shape": "Stripe_GetCustomersResponse",
"resolver": {
"name": "rest:get",
"service": "stripe",
"path": "/v1/customers",
"searchParams": {
"ops": [
{ "path": "created", "mapping": "$args.created" },
{ "path": "email", "mapping": "$args.email" },
{ "path": "ending_before", "mapping": "$args.ending_before" },
{ "path": "limit", "mapping": "$args.limit" },
{ "path": "starting_after", "mapping": "$args.starting_after" }
],
"serialize": {
"paths": {
"created": { "explode": true, "style": "deepObject" },
"email": { "style": "form" },
"ending_before": { "style": "form" },
"limit": { "style": "form" },
"starting_after": { "style": "form" }
}
}
}
},
"description": "<p>Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.</p>",
"args": {
"type": "object",
"properties": {
"created": {},
"email": { "type": "string" },
"ending_before": { "type": "string" },
"limit": { "type": "integer" },
"starting_after": { "type": "string" }
},
"required": []
}
},
"Stripe_getCustomersCustomer": {
"shape": "Stripe_GetCustomersCustomerResponse",
"resolver": {
"name": "rest:get",
"service": "stripe",
"path": {
"ops": [{ "path": "customer", "mapping": "$args.customer" }],
"serialize": {
"template": "/v1/customers/{customer}",
"paths": { "customer": { "style": "simple" } }
}
}
},
"description": "<p>Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer creation.</p>",
"args": {
"type": "object",
"properties": { "customer": { "type": "string" } },
"required": ["customer"]
}
}
},
"mutations": {
"Stripe_postCustomersCustomer": {
"shape": "Stripe_Customer",
"resolver": {
"name": "rest:post",
"service": "stripe",
"path": {
"ops": [{ "path": "customer", "mapping": "$args.customer" }],
"serialize": {
"template": "/v1/customers/{customer}",
"paths": { "customer": { "style": "simple" } }
}
},
"form": {
"ops": [{ "path": "$", "mapping": "$args.input" }],
"serialize": {
"paths": {
"address": { "explode": true, "style": "deepObject" },
"bank_account": { "explode": true, "style": "deepObject" },
"card": { "explode": true, "style": "deepObject" },
"expand": { "explode": true, "style": "deepObject" },
"invoice_settings": { "explode": true, "style": "deepObject" },
"metadata": { "explode": true, "style": "deepObject" },
"preferred_locales": { "explode": true, "style": "deepObject" },
"shipping": { "explode": true, "style": "deepObject" },
"tax": { "explode": true, "style": "deepObject" },
"trial_end": { "explode": true, "style": "deepObject" }
}
}
}
},
"description": "<p>Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the <strong>source</strong> parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the <strong>source</strong> parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the <code>past_due</code> state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the <strong>default_source</strong> for a customer will not trigger this behavior.</p>\n\n<p>This request accepts mostly the same arguments as the customer creation call.</p>",
"args": {
"type": "object",
"properties": {
"input": {
"properties": {
"address": { "type": "object" },
"balance": {
"description": "An integer amount in %s that represents the customer's current balance, which affect the customer's future invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.",
"type": "integer"
},
"bank_account": { "type": "object" },
"card": { "type": "object" },
"coupon": { "maxLength": 5000, "type": "string" },
"default_alipay_account": {
"description": "ID of Alipay account to make the customer's new default for invoice payments.",
"maxLength": 500,
"type": "string"
},
"default_bank_account": {
"description": "ID of bank account to make the customer's new default for invoice payments.",
"maxLength": 500,
"type": "string"
},
"default_card": {
"description": "ID of card to make the customer's new default for invoice payments.",
"maxLength": 500,
"type": "string"
},
"default_source": {
"description": "If you are using payment methods created via the PaymentMethods API, see the [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method) parameter.\n\nProvide the ID of a payment source already attached to this customer to make it this customer's default payment source.\n\nIf you want to add a new payment source and make it the default, see the [source](https://stripe.com/docs/api/customers/update#update_customer-source) property.",
"maxLength": 500,
"type": "string"
},
"description": {
"description": "An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard.",
"maxLength": 5000,
"type": "string"
},
"email": {
"description": "Customer's email address. It's displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to *512 characters*.",
"maxLength": 512,
"type": "string"
},
"expand": {
"description": "Specifies which fields in the response should be expanded.",
"items": { "maxLength": 5000, "type": "string" },
"type": "array"
},
"invoice_prefix": {
"description": "The prefix for the customer used to generate unique invoice numbers. Must be 3–12 uppercase letters or numbers.",
"maxLength": 5000,
"type": "string"
},
"invoice_settings": {
"description": "Default invoice settings for this customer.",
"properties": {
"custom_fields": { "type": "object" },
"default_payment_method": {
"maxLength": 5000,
"type": "string"
},
"footer": { "maxLength": 5000, "type": "string" }
},
"title": "customer_param",
"type": "object"
},
"metadata": { "type": "object" },
"name": {
"description": "The customer's full name or business name.",
"maxLength": 256,
"type": "string"
},
"next_invoice_sequence": {
"description": "The sequence to be used on the customer's next invoice. Defaults to 1.",
"type": "integer"
},
"phone": {
"description": "The customer's phone number.",
"maxLength": 20,
"type": "string"
},
"preferred_locales": {
"description": "Customer's preferred languages, ordered by preference.",
"items": { "maxLength": 5000, "type": "string" },
"type": "array"
},
"promotion_code": {
"description": "The API ID of a promotion code to apply to the customer. The customer will have a discount applied on all recurring payments. Charges you create through the API will not have the discount.",
"maxLength": 5000,
"type": "string"
},
"shipping": { "type": "object" },
"source": { "maxLength": 5000, "type": "string" },
"tax": {
"description": "Tax details about the customer.",
"properties": { "ip_address": { "type": "object" } },
"title": "tax_param",
"type": "object"
},
"tax_exempt": {
"description": "The customer's tax exemption. One of `none`, `exempt`, or `reverse`.",
"enum": ["", "exempt", "none", "reverse"]
},
"trial_end": { "type": "object" }
},
"type": "object"
},
"customer": { "type": "string" }
},
"required": ["customer"]
}
}
},
"shapes": {},
"workflows": {},
"forms": {},
"services": {
"stripe": {
"id": "stripe",
"provider": "stripe",
"title": "Stripe",
"namespace": "Stripe",
"serviceType": "openapi",
"authenticationType": "bearer",
"authentication": "h9Bko7j8IX01qaxKvuoFXeK076iteugW/hMRwb8GxjcIyU7PLVbo6PvvHqzRo5vFoC+Onskago8Wivw0WCPi3FSEsoV9MRwKdDp+wbqgdQn4UByf4RIE4NY4DYd+SeNlXYoy4nSC10FUKZ9kmEADYqWoZ6U5Hiof3wWOY5kcUlWKQ9a/gsKN",
"options": {
"endpoint": "https://api.stripe.com/",
"spec": "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment