Sha256: 3b23127bfe533e00c00b561d3c9199ba24ed45a955758326ceefe8c169b58d08

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

module SynapsePayments
  class Users

    def initialize(client)
      @client = client
    end

    def all
      @client.get(path: '/users')
    end

    def authenticate_as(id:, refresh_token:)
      response = @client.post(path: "/oauth/#{id}", json: { refresh_token: refresh_token })
      UserClient.new(@client, id, response)
    end

    def create(name:, email:, phone:, is_business: false, **args)
      data = {
        logins: email.is_a?(Array) ? email : [{ email: email }],
        phone_numbers: phone.is_a?(Array) ? phone : [phone],
        legal_names: name.is_a?(Array) ? name : [name],
        extra: {
          note: args[:note],
          supp_id: args[:supp_id],
          is_business: is_business
        }
      }

      @client.post(path: '/users', json: data)
    end

    def find(id)
      @client.get(path: "/users/#{id}")
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
synapse_payments-0.1.1 lib/synapse_payments/users.rb
synapse_payments-0.1.0 lib/synapse_payments/users.rb