Class: BaseApi::Client

Inherits:
Object
  • Object
show all
Includes:
Authorizations, Categories, ItemCategories, Items, Orders, Users, Configurable, HTTParty
Defined in:
lib/base_api/client.rb,
lib/base_api/client/items.rb,
lib/base_api/client/users.rb,
lib/base_api/client/orders.rb,
lib/base_api/client/categories.rb,
lib/base_api/client/authorizations.rb,
lib/base_api/client/item_categories.rb

Overview

TODO: 責務でクラス分ける

Defined Under Namespace

Modules: Authorizations, Categories, ItemCategories, Items, Orders, Users

Instance Attribute Summary collapse

Attributes included from Configurable

#limit, #redirect_uri

Instance Method Summary collapse

Methods included from Orders

#orders, #orders_detail

Methods included from ItemCategories

#item_categories_add, #item_categories_delete, #item_categories_detail

Methods included from Categories

#categories, #categories_add, #categories_delete, #categories_edit

Methods included from Items

#items, #items_add, #items_add_image, #items_delete, #items_delete_image, #items_delete_variation, #items_detail, #items_edit, #items_edit_stock, #items_search

Methods included from Users

#users_me

Methods included from Authorizations

#oauth_access_token, #oauth_refresh_token

Methods included from Configurable

#configure, keys, #reset!

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



28
29
30
31
32
33
34
35
# File 'lib/base_api/client.rb', line 28

def initialize(options = {})
  BaseApi::Configurable.keys.each do |key|
    value = options.key?(key) ? options[key] : BaseApi.instance_variable_get(:"@#{key}")
    instance_variable_set(:"@#{key}", value)
  end

  yield(self) if block_given?
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



25
26
27
# File 'lib/base_api/client.rb', line 25

def access_token
  @access_token
end

#client_idObject

Returns the value of attribute client_id.



25
26
27
# File 'lib/base_api/client.rb', line 25

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



25
26
27
# File 'lib/base_api/client.rb', line 25

def client_secret
  @client_secret
end

#codeObject

Returns the value of attribute code.



25
26
27
# File 'lib/base_api/client.rb', line 25

def code
  @code
end

#offsetObject

Returns the value of attribute offset.



25
26
27
# File 'lib/base_api/client.rb', line 25

def offset
  @offset
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



25
26
27
# File 'lib/base_api/client.rb', line 25

def refresh_token
  @refresh_token
end

#responseObject

Returns the value of attribute response.



25
26
27
# File 'lib/base_api/client.rb', line 25

def response
  @response
end

Instance Method Details

#fetch_next_page(&callback) ⇒ Object



48
49
50
# File 'lib/base_api/client.rb', line 48

def fetch_next_page(&callback)
  paginate(@last_page_args[:path], next_page_payload, &callback)
end

#inspectObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/base_api/client.rb', line 37

def inspect
  inspected = super

  inspected.gsub! @code, '*******' if @code
  inspected.gsub! @access_token, "#{'*'*28}#{@access_token[28..-1]}" if @access_token
  inspected.gsub! @refresh_token, "#{'*'*28}#{@refresh_token[28..-1]}" if @refresh_token
  inspected.gsub! @client_secret, "#{'*'*28}#{@client_secret[28..-1]}" if @client_secret

  inspected
end

#reset_responseObject



52
53
54
55
# File 'lib/base_api/client.rb', line 52

def reset_response
  @response = nil
  @last_page_args = nil
end