Sha256: 048085999e94ae63ba5fb8ca5c32804649dc4f255d14aa605a1690376911edaa

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

module Paddle
  class Customer < Object

    class << self

      def list(**params)
        response = Client.get_request("customers", params: params)
        Collection.from_response(response, type: Customer)
      end

      def create(email:, **params)
        attrs = {email: email.gsub(/\s+/, "")}
        response = Client.post_request("customers", body: attrs.merge(params))
        Customer.new(response.body["data"])
      end

      def retrieve(id:)
        response = Client.get_request("customers/#{id}")
        Customer.new(response.body["data"])
      end

      def update(id:, **params)
        response = Client.patch_request("customers/#{id}", body: params)
        Customer.new(response.body["data"])
      end

      def credit(id:)
        response = Client.get_request("customers/#{id}/credit-balances")
        CreditBalance.new(response.body["data"][0])
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paddle-2.2.0 lib/paddle/models/customer.rb
paddle-2.1.4 lib/paddle/models/customer.rb
paddle-2.1.3 lib/paddle/models/customer.rb
paddle-2.1.2 lib/paddle/models/customer.rb