Module: Pinterest
- Defined in:
- lib/pinterest.rb,
lib/pinterest/error.rb,
lib/pinterest/client.rb,
lib/pinterest/version.rb,
lib/pinterest/response.rb,
lib/pinterest/connection.rb,
lib/pinterest/configuration.rb,
lib/pinterest/resources/base.rb,
lib/pinterest/resources/oauth.rb,
lib/pinterest/resources/audiences.rb,
lib/pinterest/resources/customer_lists.rb,
lib/pinterest/resources/customer_list_uploads.rb
Defined Under Namespace
Modules: Connection, Resources
Classes: AuthenticationError, BadRequestError, Client, Configuration, Error, ForbiddenError, NotFoundError, RateLimitError, Response, ServerError
Constant Summary
collapse
- HTTP_ERROR_MAP =
{
400 => BadRequestError,
401 => AuthenticationError,
403 => ForbiddenError,
404 => NotFoundError,
429 => RateLimitError,
}.freeze
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
10
11
12
|
# File 'lib/pinterest.rb', line 10
def configuration
@configuration ||= Configuration.new
end
|
Configure the gem globally.
Pinterest.configure do |c|
c.client_id = ENV["PINTEREST_CLIENT_ID"]
c.client_secret = ENV["PINTEREST_CLIENT_SECRET"]
end
20
21
22
|
# File 'lib/pinterest.rb', line 20
def configure
yield configuration
end
|
.error_for(status, body, response) ⇒ Object
28
29
30
31
32
|
# File 'lib/pinterest/error.rb', line 28
def self.error_for(status, body, response)
klass = HTTP_ERROR_MAP.fetch(status) { status >= 500 ? ServerError : Error }
message = body.is_a?(Hash) ? body["message"] : body.to_s
klass.new(message, status: status, code: body.is_a?(Hash) ? body["code"] : nil, response: response)
end
|
.reset_configuration! ⇒ Object
24
25
26
|
# File 'lib/pinterest.rb', line 24
def reset_configuration!
@configuration = Configuration.new
end
|