Class: Monri::Customers

Inherits:
Object
  • Object
show all
Defined in:
lib/monri/customers.rb,
lib/monri/customers/create_response.rb

Defined Under Namespace

Classes: CreateResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokens=(value) ⇒ Monri::AccessTokens (writeonly)

Returns:



8
9
10
# File 'lib/monri/customers.rb', line 8

def access_tokens=(value)
  @access_tokens = value
end

#configMonri::Config

Returns:



4
5
6
# File 'lib/monri/customers.rb', line 4

def config
  @config
end

#http_client=(value) ⇒ Monri::HttpClient (writeonly)

Returns:



6
7
8
# File 'lib/monri/customers.rb', line 6

def http_client=(value)
  @http_client = value
end

Instance Method Details

#create(options) ⇒ Object

Parameters:

  • options (Hash)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/monri/customers.rb', line 11

def create(options)
  CreateResponse.create do
    token_rv = @access_tokens.create!(scopes: ['customers'])
    response = @http_client.post('/v2/customers', options, oauth: token_rv.access_token)

    if response.failed?
      raise response.exception
    elsif response.success?
      response.body
    else
      # TODO: handle this case
    end
  end
end