Class: Pinterest::Client

Inherits:
Object
  • Object
show all
Includes:
HTTP
Defined in:
lib/pinterest/client.rb

Constant Summary collapse

CONFIG_KEYS =
%i[
  api_type
  api_version
  access_token
  refresh_token
  client_id
  secret_key
  uri_base
  request_timeout
  extra_headers
].freeze

Instance Method Summary collapse

Methods included from HTTP

#delete, #get, #json_post, #multipart_post, #oauth_post, #patch

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
# File 'lib/pinterest/client.rb', line 18

def initialize(config = {})
  CONFIG_KEYS.each do |key|
    # Set instance variables like api_type & access_token. Fall back to global config
    # if not present.
    instance_variable_set("@#{key}", config[key] || Pinterest.configuration.send(key))
  end
end

Instance Method Details

#boardsObject



26
27
28
# File 'lib/pinterest/client.rb', line 26

def boards
  @boards ||= Pinterest::Boards.new(client: self)
end

#keywordsObject



38
39
40
# File 'lib/pinterest/client.rb', line 38

def keywords
  @pins ||= Pinterest::Keywords.new(client: self)
end

#mediaObject



46
47
48
# File 'lib/pinterest/client.rb', line 46

def media
  @media ||= Pinterest::Media.new(client: self)
end

#oauthObject



42
43
44
# File 'lib/pinterest/client.rb', line 42

def oauth
  @oauth ||= Pinterest::Oauth.new(client: self)
end

#pinsObject



30
31
32
# File 'lib/pinterest/client.rb', line 30

def pins
  @pins ||= Pinterest::Pins.new(client: self)
end

#termsObject



34
35
36
# File 'lib/pinterest/client.rb', line 34

def terms
  @terms ||= Pinterest::Terms.new(client: self)
end

#user_accountObject



50
51
52
# File 'lib/pinterest/client.rb', line 50

def 
  @user_account ||= Pinterest::UserAccount.new(client: self)
end