Module: Pipedrive

Defined in:
lib/pipedrive.rb,
lib/pipedrive/util.rb,
lib/pipedrive/merge.rb,
lib/pipedrive/errors.rb,
lib/pipedrive/fields.rb,
lib/pipedrive/version.rb,
lib/pipedrive/resource.rb,
lib/pipedrive/resources/deal.rb,
lib/pipedrive/resources/file.rb,
lib/pipedrive/resources/goal.rb,
lib/pipedrive/resources/lead.rb,
lib/pipedrive/resources/note.rb,
lib/pipedrive/resources/team.rb,
lib/pipedrive/resources/user.rb,
lib/pipedrive/resources/stage.rb,
lib/pipedrive/resources/filter.rb,
lib/pipedrive/resources/person.rb,
lib/pipedrive/resources/product.rb,
lib/pipedrive/resources/webhook.rb,
lib/pipedrive/resources/activity.rb,
lib/pipedrive/resources/call_log.rb,
lib/pipedrive/resources/currency.rb,
lib/pipedrive/resources/pipeline.rb,
lib/pipedrive/resources/lead_label.rb,
lib/pipedrive/api_operations/create.rb,
lib/pipedrive/api_operations/delete.rb,
lib/pipedrive/api_operations/update.rb,
lib/pipedrive/resources/lead_source.rb,
lib/pipedrive/resources/participant.rb,
lib/pipedrive/api_operations/request.rb,
lib/pipedrive/resources/organization.rb,
lib/pipedrive/resources/subscription.rb,
lib/pipedrive/resources/activity_type.rb,
lib/pipedrive/resources/global_message.rb,
lib/pipedrive/resources/organization_field.rb

Defined Under Namespace

Modules: APIOperations, Fields, Merge, Util Classes: Activity, ActivityType, AuthenticationError, BadRequestError, CallLog, Currency, Deal, File, Filter, ForbiddenError, GlobalMessage, Goal, GoneError, InternalServerError, Lead, LeadLabel, LeadSource, MethodNotAllowedError, NotFoundError, NotImplementedError, Note, Organization, OrganizationField, Participant, PaymentRequiredError, Person, PipedriveError, Pipeline, Product, Resource, ServiceUnavailableError, SettingError, Stage, Subscription, Team, TooManyRequestsError, UnauthorizedError, UnkownAPIError, UnprocessableEntityError, UnsupportedMediaTypeError, User, Webhook

Constant Summary collapse

BASE_URL =
"https://api.pipedrive.com/v1"
ERROR_CLASS_MAP =
{
  "400" => BadRequestError,
  "401" => UnauthorizedError,
  "402" => PaymentRequiredError,
  "403" => ForbiddenError,
  "404" => NotFoundError,
  "405" => MethodNotAllowedError,
  "410" => GoneError,
  "415" => UnsupportedMediaTypeError,
  "422" => UnprocessableEntityError,
  "429" => TooManyRequestsError,
  "500" => InternalServerError,
  "501" => NotImplementedError,
  "503" => ServiceUnavailableError,
}.freeze
VERSION =
"1.3.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

.debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

.debug_httpObject

Returns the value of attribute debug_http.



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

def debug_http
  @debug_http
end

.debug_http_bodyObject

Returns the value of attribute debug_http_body.



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

def debug_http_body
  @debug_http_body
end

.loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

.treat_no_content_as_not_foundObject

Returns the value of attribute treat_no_content_as_not_found.



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

def treat_no_content_as_not_found
  @treat_no_content_as_not_found
end

Class Method Details

.raise_error(status, response) ⇒ Object

Raises:

  • (error_class)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/pipedrive/errors.rb', line 54

def raise_error(status, response)
  return if [200, 201].include?(status)

  message =
    [response.dig(:error), response.dig(:error_info)]
    .compact
    .join(". ")

  error_data =
    response
    .fetch(:data, {})
    .inspect
    .concat(response.fetch(:additional_data, {}).inspect)

  error_class = ERROR_CLASS_MAP[status.to_s]
  raise error_class.new(message, status, error_data) if error_class

  raise UnkownAPIError.new(message, status, error_data)
end