lemonsqueezy 0.2.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +2 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +13 -9
- data/README.md +203 -65
- data/bin/console +3 -1
- data/lib/lemon_squeezy/client.rb +57 -59
- data/lib/lemon_squeezy/configuration.rb +12 -0
- data/lib/lemon_squeezy/models/checkout.rb +46 -0
- data/lib/lemon_squeezy/models/customer.rb +52 -0
- data/lib/lemon_squeezy/models/discount.rb +47 -0
- data/lib/lemon_squeezy/models/discount_redemption.rb +19 -0
- data/lib/lemon_squeezy/models/file.rb +19 -0
- data/lib/lemon_squeezy/models/license.rb +24 -0
- data/lib/lemon_squeezy/models/license_key.rb +32 -0
- data/lib/lemon_squeezy/models/license_key_instance.rb +19 -0
- data/lib/lemon_squeezy/models/order.rb +24 -0
- data/lib/lemon_squeezy/models/price.rb +19 -0
- data/lib/lemon_squeezy/models/product.rb +19 -0
- data/lib/lemon_squeezy/models/store.rb +19 -0
- data/lib/lemon_squeezy/models/subscription.rb +99 -0
- data/lib/lemon_squeezy/models/subscription_invoice.rb +19 -0
- data/lib/lemon_squeezy/models/subscription_item.rb +38 -0
- data/lib/lemon_squeezy/models/subscription_usage.rb +4 -0
- data/lib/lemon_squeezy/models/user.rb +14 -0
- data/lib/lemon_squeezy/models/variant.rb +19 -0
- data/lib/lemon_squeezy/models/webhook.rb +58 -0
- data/lib/lemon_squeezy/object.rb +15 -1
- data/lib/lemon_squeezy/version.rb +1 -1
- data/lib/lemon_squeezy.rb +34 -27
- metadata +23 -27
- data/lib/lemon_squeezy/objects/checkout.rb +0 -12
- data/lib/lemon_squeezy/objects/customer.rb +0 -12
- data/lib/lemon_squeezy/objects/discount.rb +0 -12
- data/lib/lemon_squeezy/objects/file.rb +0 -12
- data/lib/lemon_squeezy/objects/license_key.rb +0 -12
- data/lib/lemon_squeezy/objects/license_key_instance.rb +0 -12
- data/lib/lemon_squeezy/objects/order.rb +0 -12
- data/lib/lemon_squeezy/objects/order_item.rb +0 -12
- data/lib/lemon_squeezy/objects/product.rb +0 -12
- data/lib/lemon_squeezy/objects/store.rb +0 -12
- data/lib/lemon_squeezy/objects/subscription.rb +0 -12
- data/lib/lemon_squeezy/objects/variant.rb +0 -12
- data/lib/lemon_squeezy/resource.rb +0 -60
- data/lib/lemon_squeezy/resources/checkouts.rb +0 -42
- data/lib/lemon_squeezy/resources/customers.rb +0 -15
- data/lib/lemon_squeezy/resources/discounts.rb +0 -15
- data/lib/lemon_squeezy/resources/files.rb +0 -15
- data/lib/lemon_squeezy/resources/license_key_instances.rb +0 -15
- data/lib/lemon_squeezy/resources/license_keys.rb +0 -15
- data/lib/lemon_squeezy/resources/orders.rb +0 -20
- data/lib/lemon_squeezy/resources/products.rb +0 -15
- data/lib/lemon_squeezy/resources/stores.rb +0 -15
- data/lib/lemon_squeezy/resources/subscriptions.rb +0 -92
- data/lib/lemon_squeezy/resources/variants.rb +0 -15
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lemonsqueezy
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dean Perry
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-01-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -42,32 +42,28 @@ files: | |
| 42 42 | 
             
            - lib/lemon_squeezy.rb
         | 
| 43 43 | 
             
            - lib/lemon_squeezy/client.rb
         | 
| 44 44 | 
             
            - lib/lemon_squeezy/collection.rb
         | 
| 45 | 
            +
            - lib/lemon_squeezy/configuration.rb
         | 
| 45 46 | 
             
            - lib/lemon_squeezy/error.rb
         | 
| 47 | 
            +
            - lib/lemon_squeezy/models/checkout.rb
         | 
| 48 | 
            +
            - lib/lemon_squeezy/models/customer.rb
         | 
| 49 | 
            +
            - lib/lemon_squeezy/models/discount.rb
         | 
| 50 | 
            +
            - lib/lemon_squeezy/models/discount_redemption.rb
         | 
| 51 | 
            +
            - lib/lemon_squeezy/models/file.rb
         | 
| 52 | 
            +
            - lib/lemon_squeezy/models/license.rb
         | 
| 53 | 
            +
            - lib/lemon_squeezy/models/license_key.rb
         | 
| 54 | 
            +
            - lib/lemon_squeezy/models/license_key_instance.rb
         | 
| 55 | 
            +
            - lib/lemon_squeezy/models/order.rb
         | 
| 56 | 
            +
            - lib/lemon_squeezy/models/price.rb
         | 
| 57 | 
            +
            - lib/lemon_squeezy/models/product.rb
         | 
| 58 | 
            +
            - lib/lemon_squeezy/models/store.rb
         | 
| 59 | 
            +
            - lib/lemon_squeezy/models/subscription.rb
         | 
| 60 | 
            +
            - lib/lemon_squeezy/models/subscription_invoice.rb
         | 
| 61 | 
            +
            - lib/lemon_squeezy/models/subscription_item.rb
         | 
| 62 | 
            +
            - lib/lemon_squeezy/models/subscription_usage.rb
         | 
| 63 | 
            +
            - lib/lemon_squeezy/models/user.rb
         | 
| 64 | 
            +
            - lib/lemon_squeezy/models/variant.rb
         | 
| 65 | 
            +
            - lib/lemon_squeezy/models/webhook.rb
         | 
| 46 66 | 
             
            - lib/lemon_squeezy/object.rb
         | 
| 47 | 
            -
            - lib/lemon_squeezy/objects/checkout.rb
         | 
| 48 | 
            -
            - lib/lemon_squeezy/objects/customer.rb
         | 
| 49 | 
            -
            - lib/lemon_squeezy/objects/discount.rb
         | 
| 50 | 
            -
            - lib/lemon_squeezy/objects/file.rb
         | 
| 51 | 
            -
            - lib/lemon_squeezy/objects/license_key.rb
         | 
| 52 | 
            -
            - lib/lemon_squeezy/objects/license_key_instance.rb
         | 
| 53 | 
            -
            - lib/lemon_squeezy/objects/order.rb
         | 
| 54 | 
            -
            - lib/lemon_squeezy/objects/order_item.rb
         | 
| 55 | 
            -
            - lib/lemon_squeezy/objects/product.rb
         | 
| 56 | 
            -
            - lib/lemon_squeezy/objects/store.rb
         | 
| 57 | 
            -
            - lib/lemon_squeezy/objects/subscription.rb
         | 
| 58 | 
            -
            - lib/lemon_squeezy/objects/variant.rb
         | 
| 59 | 
            -
            - lib/lemon_squeezy/resource.rb
         | 
| 60 | 
            -
            - lib/lemon_squeezy/resources/checkouts.rb
         | 
| 61 | 
            -
            - lib/lemon_squeezy/resources/customers.rb
         | 
| 62 | 
            -
            - lib/lemon_squeezy/resources/discounts.rb
         | 
| 63 | 
            -
            - lib/lemon_squeezy/resources/files.rb
         | 
| 64 | 
            -
            - lib/lemon_squeezy/resources/license_key_instances.rb
         | 
| 65 | 
            -
            - lib/lemon_squeezy/resources/license_keys.rb
         | 
| 66 | 
            -
            - lib/lemon_squeezy/resources/orders.rb
         | 
| 67 | 
            -
            - lib/lemon_squeezy/resources/products.rb
         | 
| 68 | 
            -
            - lib/lemon_squeezy/resources/stores.rb
         | 
| 69 | 
            -
            - lib/lemon_squeezy/resources/subscriptions.rb
         | 
| 70 | 
            -
            - lib/lemon_squeezy/resources/variants.rb
         | 
| 71 67 | 
             
            - lib/lemon_squeezy/version.rb
         | 
| 72 68 | 
             
            - lib/lemonsqueezy.rb
         | 
| 73 69 | 
             
            homepage: https://github.com/deanpcmad/lemonsqueezy
         | 
| @@ -90,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 90 86 | 
             
                - !ruby/object:Gem::Version
         | 
| 91 87 | 
             
                  version: '0'
         | 
| 92 88 | 
             
            requirements: []
         | 
| 93 | 
            -
            rubygems_version: 3.4. | 
| 89 | 
            +
            rubygems_version: 3.4.22
         | 
| 94 90 | 
             
            signing_key: 
         | 
| 95 91 | 
             
            specification_version: 4
         | 
| 96 92 | 
             
            summary: Ruby library for interacting with the Lemon Squeezy API
         | 
| @@ -1,60 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class Resource
         | 
| 3 | 
            -
                attr_reader :client
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                def initialize(client)
         | 
| 6 | 
            -
                  @client = client
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                private
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                def get_request(url, params: {}, headers: {})
         | 
| 12 | 
            -
                  handle_response client.connection.get(url, params, headers)
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def post_request(url, body: {}, headers: {})
         | 
| 16 | 
            -
                  handle_response client.connection.post(url, body, headers)
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                def patch_request(url, body:, headers: {})
         | 
| 20 | 
            -
                  handle_response client.connection.patch(url, body, headers)
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                def put_request(url, body:, headers: {})
         | 
| 24 | 
            -
                  handle_response client.connection.put(url, body, headers)
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                def delete_request(url, params: {}, headers: {})
         | 
| 28 | 
            -
                  handle_response client.connection.delete(url, params, headers)
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                def handle_response(response)
         | 
| 32 | 
            -
                  case response.status
         | 
| 33 | 
            -
                  when 400
         | 
| 34 | 
            -
                    raise Error, "Error 400: Your request was malformed. '#{response.body["errors"][0]["detail"]}'"
         | 
| 35 | 
            -
                  when 401
         | 
| 36 | 
            -
                    raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["error"]}'"
         | 
| 37 | 
            -
                  when 403
         | 
| 38 | 
            -
                    raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["error"]}'"
         | 
| 39 | 
            -
                  when 404
         | 
| 40 | 
            -
                    raise Error, "Error 404: No results were found for your request. '#{response.body["error"]}'"
         | 
| 41 | 
            -
                  when 409
         | 
| 42 | 
            -
                    raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
         | 
| 43 | 
            -
                  when 429
         | 
| 44 | 
            -
                    raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["error"]}'"
         | 
| 45 | 
            -
                  when 500
         | 
| 46 | 
            -
                    raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["error"]}'"
         | 
| 47 | 
            -
                  when 503
         | 
| 48 | 
            -
                    raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["error"]}'"
         | 
| 49 | 
            -
                  when 501
         | 
| 50 | 
            -
                    raise Error, "Error 501: This resource has not been implemented. '#{response.body["error"]}'"
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                  if response.body && response.body["error"]
         | 
| 54 | 
            -
                    raise Error, "Error #{response.body["error"]["code"]} - #{response.body["error"]["message"]}"
         | 
| 55 | 
            -
                  end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  response
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
              end
         | 
| 60 | 
            -
            end
         | 
| @@ -1,42 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class CheckoutsResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("checkouts", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Customer)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("checkouts/#{id}")
         | 
| 11 | 
            -
                  Customer.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def create(store_id:, variant_id:, **attrs)
         | 
| 15 | 
            -
                  data = {}
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  data["type"] = "checkouts"
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  data["relationships"] = {
         | 
| 20 | 
            -
                    store: {
         | 
| 21 | 
            -
                      data: {
         | 
| 22 | 
            -
                        type: "stores",
         | 
| 23 | 
            -
                        id: store_id.to_s
         | 
| 24 | 
            -
                      }
         | 
| 25 | 
            -
                    },
         | 
| 26 | 
            -
                    variant: {
         | 
| 27 | 
            -
                      data: {
         | 
| 28 | 
            -
                        type: "variants",
         | 
| 29 | 
            -
                        id: variant_id.to_s
         | 
| 30 | 
            -
                      }
         | 
| 31 | 
            -
                    }
         | 
| 32 | 
            -
                  }
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  data["attributes"] = attrs
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  response = post_request("checkouts", body: {data: data}.to_json)
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  Checkout.new(response.body["data"]) if response.success?
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class CustomersResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("customers", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Customer)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("customers/#{id}")
         | 
| 11 | 
            -
                  Customer.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class DiscountsResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("discounts", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Discount)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("discounts/#{id}")
         | 
| 11 | 
            -
                  Discount.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class FilesResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("files", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: File)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("files/#{id}")
         | 
| 11 | 
            -
                  File.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class LicenseKeyInstancesResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("license-key-instances", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: LicenseKeyInstance)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("license-key-instances/#{id}")
         | 
| 11 | 
            -
                  LicenseKeyInstance.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class LicenseKeysResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("license-keys", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: LicenseKey)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("license-keys/#{id}")
         | 
| 11 | 
            -
                  LicenseKey.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class OrdersResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("orders", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Order)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("orders/#{id}")
         | 
| 11 | 
            -
                  Order.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def order_items(id:)
         | 
| 15 | 
            -
                  response = get_request("order-items", params: {order_id: id})
         | 
| 16 | 
            -
                  Collection.from_response(response, type: OrderItem)
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class ProductsResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("products", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Product)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("products/#{id}")
         | 
| 11 | 
            -
                  Product.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class StoresResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list
         | 
| 5 | 
            -
                  response = get_request("stores")
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Store)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("stores/#{id}")
         | 
| 11 | 
            -
                  Store.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,92 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class SubscriptionsResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("subscriptions", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Subscription)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("subscriptions/#{id}")
         | 
| 11 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                # Kind: void or free
         | 
| 15 | 
            -
                def pause(id:, kind:, resumes_at: nil)
         | 
| 16 | 
            -
                  body = {
         | 
| 17 | 
            -
                    data: {
         | 
| 18 | 
            -
                      type: "subscriptions",
         | 
| 19 | 
            -
                      id: id.to_s,
         | 
| 20 | 
            -
                      attributes: {
         | 
| 21 | 
            -
                        pause: {mode: kind, resumes_at: resumes_at}
         | 
| 22 | 
            -
                      }
         | 
| 23 | 
            -
                    }
         | 
| 24 | 
            -
                  }
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  response = patch_request("subscriptions/#{id}", body: body.to_json)
         | 
| 27 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                def unpause(id:)
         | 
| 31 | 
            -
                  body = {
         | 
| 32 | 
            -
                    data: {
         | 
| 33 | 
            -
                      type: "subscriptions",
         | 
| 34 | 
            -
                      id: id.to_s,
         | 
| 35 | 
            -
                      attributes: {
         | 
| 36 | 
            -
                        pause: nil
         | 
| 37 | 
            -
                      }
         | 
| 38 | 
            -
                    }
         | 
| 39 | 
            -
                  }
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                  response = patch_request("subscriptions/#{id}", body: body.to_json)
         | 
| 42 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                def cancel(id:)
         | 
| 46 | 
            -
                  body = {
         | 
| 47 | 
            -
                    data: {
         | 
| 48 | 
            -
                      type: "subscriptions",
         | 
| 49 | 
            -
                      id: id.to_s,
         | 
| 50 | 
            -
                      attributes: {
         | 
| 51 | 
            -
                        cancelled: true
         | 
| 52 | 
            -
                      }
         | 
| 53 | 
            -
                    }
         | 
| 54 | 
            -
                  }
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                  response = patch_request("subscriptions/#{id}", body: body.to_json)
         | 
| 57 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                def uncancel(id:)
         | 
| 61 | 
            -
                  body = {
         | 
| 62 | 
            -
                    data: {
         | 
| 63 | 
            -
                      type: "subscriptions",
         | 
| 64 | 
            -
                      id: id.to_s,
         | 
| 65 | 
            -
                      attributes: {
         | 
| 66 | 
            -
                        cancelled: false
         | 
| 67 | 
            -
                      }
         | 
| 68 | 
            -
                    }
         | 
| 69 | 
            -
                  }
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  response = patch_request("subscriptions/#{id}", body: body.to_json)
         | 
| 72 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 73 | 
            -
                end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                def change_plan(id:, plan_id:, variant_id:)
         | 
| 76 | 
            -
                  body = {
         | 
| 77 | 
            -
                    data: {
         | 
| 78 | 
            -
                      type: "subscriptions",
         | 
| 79 | 
            -
                      id: id.to_s,
         | 
| 80 | 
            -
                      attributes: {
         | 
| 81 | 
            -
                        product_id: plan_id,
         | 
| 82 | 
            -
                        variant_id: variant_id
         | 
| 83 | 
            -
                      }
         | 
| 84 | 
            -
                    }
         | 
| 85 | 
            -
                  }
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                  response = patch_request("subscriptions/#{id}", body: body.to_json)
         | 
| 88 | 
            -
                  Subscription.new(response.body["data"]) if response.success?
         | 
| 89 | 
            -
                end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
              end
         | 
| 92 | 
            -
            end
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module LemonSqueezy
         | 
| 2 | 
            -
              class VariantsResource < Resource
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def list(**params)
         | 
| 5 | 
            -
                  response = get_request("variants", params: params)
         | 
| 6 | 
            -
                  Collection.from_response(response, type: Variant)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def get(id:)
         | 
| 10 | 
            -
                  response = get_request("variants/#{id}")
         | 
| 11 | 
            -
                  Variant.new(response.body["data"]) if response.success?
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         |