Class: Procore::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/procore/configuration.rb

Overview

Holds the configuration for the Procore gem.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



101
102
103
104
105
106
107
108
109
# File 'lib/procore/configuration.rb', line 101

def initialize
  @default_batch_size = Procore::Defaults::BATCH_SIZE
  @host = Procore::Defaults::API_ENDPOINT
  @logger = nil
  @max_retries = 1
  @timeout = 1.0
  @user_agent = Procore::Defaults::USER_AGENT
  @default_version = Procore::Defaults::DEFAULT_VERSION
end

Instance Attribute Details

#default_batch_sizeInteger

Note:

defaults to Defaults::BATCH_SIZE

When using #sync action, sets the default batch size to use for chunking up a request body. Example, if the size is set to 500 and 2,000 updates are desired, 4 requests will be made.

Note: The maximum size is 1,000

Returns:

  • (Integer)


99
100
101
# File 'lib/procore/configuration.rb', line 99

def default_batch_size
  @default_batch_size
end

#default_versionString

Note:

defaults to Defaults::DEFAULT_VERSION

The default API version to use if none is specified in the request. Should be either “v1.0” (recommended) or “vapid” (legacy).

Returns:

  • (String)


42
43
44
# File 'lib/procore/configuration.rb', line 42

def default_version
  @default_version
end

#hostString

Note:

defaults to Defaults::API_ENDPOINT

Base API host name. Alter this depending on your environment - in a staging or test environment you may want to point this at a sandbox instead of production.

Returns:

  • (String)


33
34
35
# File 'lib/procore/configuration.rb', line 33

def host
  @host
end

#loggerLogger?

Note:

defaults to nil

Instance of a Logger. This gem will log information about requests, responses and other things it might be doing. In a Rails application it should be set to Rails.logger

Returns:

  • (Logger, nil)


52
53
54
# File 'lib/procore/configuration.rb', line 52

def logger
  @logger
end

#max_retriesInteger

Note:

Defaults to 1

Number of times to retry a failed API call. Reasons an API call could potentially fail:

  1. Service is briefly down or unreachable

  2. Timeout hit - service is experiencing immense load or mid restart

  3. Because computers

Would recommend 3-5 for production use. Has exponential backoff - first request waits a 1.5s after a failure, next one 2.25s, next one 3.375s, 5.0, etc.

Returns:

  • (Integer)


68
69
70
# File 'lib/procore/configuration.rb', line 68

def max_retries
  @max_retries
end

#timeoutFloat

Note:

defaults to 1.0

Threshold for canceling an API request. If a request takes longer than this value it will automatically cancel.

Returns:

  • (Float)


77
78
79
# File 'lib/procore/configuration.rb', line 77

def timeout
  @timeout
end

#user_agentString

Note:

defaults to Defaults::USER_AGENT

User Agent sent with each API request. API requests must have a user agent set. It is recomended to set the user agent to the name of your application.

Returns:

  • (String)


87
88
89
# File 'lib/procore/configuration.rb', line 87

def user_agent
  @user_agent
end