Sha256: c5709c96403f83763922f37a7dd29d31d928bc3ecca10405d9bdd8dcbd4d6be9

Contents?: true

Size: 909 Bytes

Versions: 9

Compression:

Stored size: 909 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

9 entries across 9 versions & 1 rubygems

Version Path
paddle-2.7.0 lib/paddle/models/customer.rb
paddle-2.6.0 lib/paddle/models/customer.rb
paddle-2.5.2 lib/paddle/models/customer.rb
paddle-2.5.1 lib/paddle/models/customer.rb
paddle-2.5.0 lib/paddle/models/customer.rb
paddle-2.4.1 lib/paddle/models/customer.rb
paddle-2.4.0 lib/paddle/models/customer.rb
paddle-2.3.0 lib/paddle/models/customer.rb
paddle-2.2.1 lib/paddle/models/customer.rb