Sha256: 286edb86c837e79b18c820c14af423f25f9a45d61b44fd309a3f11a1885ed52b

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

require 'erb'

module Voucherify
  module Service
    class Customers
      attr_reader :client

      def initialize(client)
        @client = client
      end

      def list(params = {})
        @client.get('/customers', params)
      end

      def create(customer)
        @client.post('/customers', customer.to_json)
      end

      def get(customer_id)
        @client.get("/customers/#{ERB::Util.url_encode(customer_id)}")
      end

      def update(customer)
        @client.put("/customers/#{ERB::Util.url_encode(customer['id'] || customer[:id])}", customer.to_json)
      end

      def delete(customer_id)
        @client.delete("/customers/#{ERB::Util.url_encode(customer_id)}")
      end

      def update_consents(customer_id, consents)
        @client.put("/customers/#{ERB::Util.url_encode(customer_id)}/consents", consents.to_json)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voucherify-4.1.0 lib/voucherify/service/customers.rb
voucherify-4.0.0 lib/voucherify/service/customers.rb