Class: Smartsheet::Client

Inherits:
Object
  • Object
show all
Includes:
Constants, GeneralRequest
Defined in:
lib/smartsheet/client.rb

Overview

The entry point to the SDK. API endpoint categories are accessed through this object's readable attributes.

Constant Summary

Constants included from Constants

Smartsheet::Constants::API_URL, Smartsheet::Constants::CSV_TYPE, Smartsheet::Constants::DEFAULT_BACKOFF_METHOD, Smartsheet::Constants::DEFAULT_MAX_RETRY_TIME, Smartsheet::Constants::EXCEL_TYPE, Smartsheet::Constants::GOV_API_URL, Smartsheet::Constants::JSON_TYPE, Smartsheet::Constants::OPENXML_SPREADSHEET_TYPE, Smartsheet::Constants::PDF_TYPE, Smartsheet::Constants::USER_AGENT, Smartsheet::Constants::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GeneralRequest

#request, #request_with_file, #request_with_file_from_path

Constructor Details

#initialize(token: nil, logger: nil, log_full_body: false, user_agent: nil, json_output: false, assume_user: nil, max_retry_time: nil, backoff_method: nil, base_url: API_URL) ⇒ Client

Returns a new instance of Client.

Parameters:

  • token (String) (defaults to: nil)

    access token for the API; if nil or empty, uses environment variable SMARTSHEET_ACCESS_TOKEN

  • logger (Logger) (defaults to: nil)

    a logger to which request and response info will be recorded

  • log_full_body (Boolean) (defaults to: false)

    when true, request and response bodies will not be truncated in the logs

  • user_agent (String) (defaults to: nil)

    the name of the application, sent as part of the user agent for requests; defaults as the name of the application

  • json_output (Boolean) (defaults to: false)

    when true, endpoints return raw JSON strings instead of hashes

  • assume_user (String) (defaults to: nil)

    the email address of the user to impersonate; only available for admin roles

  • max_retry_time (Fixnum) (defaults to: nil)

    overrides the maximum number of seconds during which eligible errors will be retried

  • backoff_method (Proc) (defaults to: nil)

    overrides the backoff calculation method, accepting the index of the current retry attempt (0-based) and returning the number of seconds to wait before retrying the call again, or :stop to halt retrying and return the latest error.

    Example - Wait 1 second before the first retry, 2 seconds before the second, and so on:

    ->(x){ x + 1 }
    

    Example - Try twice, then halt:

    ->(x){ if x < 2 then x + 1 else :stop end }
    
  • base_url (String) (defaults to: API_URL)

    overrides the base URL used when constructing API calls; for example, the default takes the form of https://api.smartsheet.com/2.0



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/smartsheet/client.rb', line 100

def initialize(
    token: nil,
    logger: nil,
    log_full_body: false,
    user_agent: nil,
    json_output: false,
    assume_user: nil,
    max_retry_time: nil,
    backoff_method: nil,
    base_url: API_URL
)

  request_logger =
      logger ?
          API::RequestLogger.new(logger, log_full_body: log_full_body) :
          API::MuteRequestLogger.new

  token = token_env_var if token.nil? || token.empty?

  app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

  net_client = API::FaradayNetClient.new

  retry_logic = init_retry_logic(max_retry_time, backoff_method)

  retrying_client = API::RetryNetClientDecorator.new(
      net_client,
      retry_logic,
      logger: request_logger
  )

  response_client = API::ResponseNetClientDecorator.new(
      retrying_client,
      json_output: json_output,
      logger: request_logger
  )

  @client = API::RequestClient.new(
      token,
      response_client,
      base_url,
      app_user_agent: app_user_agent,
      assume_user: assume_user,
      logger: request_logger
  )
  build_categories
end

Instance Attribute Details

#contactsContacts (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#eventsObject (readonly)

Returns the value of attribute events.



68
69
70
# File 'lib/smartsheet/client.rb', line 68

def events
  @events
end

#favoritesFavorites (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#foldersFolders (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#groupsGroups (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#homeHome (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#reportsReports (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#searchSearch (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#server_infoServerInfo (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#sheetsSheets (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#sightsSights (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#templatesTemplates (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#tokenToken (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#update_requestsUpdateRequests (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#usersUsers (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#webhooksWebhooks (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

#workspacesWorkspaces (readonly)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smartsheet/client.rb', line 64

class Client
  include GeneralRequest
  include Smartsheet::Constants

  attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
              :sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
              :workspaces

  # @param token [String] access token for the API; if nil or empty, uses environment variable
  #   `SMARTSHEET_ACCESS_TOKEN`
  # @param logger [Logger] a logger to which request and response info will be recorded
  # @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
  #   the logs
  # @param user_agent [String] the name of the application, sent as part of the user agent for
  #   requests; defaults as the name of the application
  # @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
  # @param assume_user [String] the email address of the user to impersonate; only available for
  #   admin roles
  # @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
  #   errors will be retried
  # @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
  #   the current retry attempt (0-based) and returning the number of seconds to wait before
  #   retrying the call again, or `:stop` to halt retrying and return the latest error.
  #
  #   Example - Wait 1 second before the first retry, 2 seconds before
  #   the second, and so on:
  #   ```ruby
  #   ->(x){ x + 1 }
  #   ```
  #
  #   Example - Try twice, then halt:
  #   ```ruby
  #   ->(x){ if x < 2 then x + 1 else :stop end }
  #   ```
  # @param base_url [String] overrides the base URL used when constructing API calls; for example,
  #   the default takes the form of `https://api.smartsheet.com/2.0`
  def initialize(
      token: nil,
      logger: nil,
      log_full_body: false,
      user_agent: nil,
      json_output: false,
      assume_user: nil,
      max_retry_time: nil,
      backoff_method: nil,
      base_url: API_URL
  )

    request_logger =
        logger ?
            API::RequestLogger.new(logger, log_full_body: log_full_body) :
            API::MuteRequestLogger.new

    token = token_env_var if token.nil? || token.empty?

    app_user_agent = user_agent.nil? ? File.basename($PROGRAM_NAME) : user_agent

    net_client = API::FaradayNetClient.new

    retry_logic = init_retry_logic(max_retry_time, backoff_method)

    retrying_client = API::RetryNetClientDecorator.new(
        net_client,
        retry_logic,
        logger: request_logger
    )

    response_client = API::ResponseNetClientDecorator.new(
        retrying_client,
        json_output: json_output,
        logger: request_logger
    )

    @client = API::RequestClient.new(
        token,
        response_client,
        base_url,
        app_user_agent: app_user_agent,
        assume_user: assume_user,
        logger: request_logger
    )
    build_categories
  end

  def inspect
    methods = (self.public_methods - Object.methods)
                  .sort
                  .map {|m| ':' + m.to_s}
                  .join(', ')

    "#<Smartsheet::Client:#{self.object_id} #{methods}>"
  end

  private

  attr_reader :client

  def build_categories
    @contacts = Contacts.new(client)
    @events = Events.new(client)
    @favorites = Favorites.new(client)
    @folders = Folders.new(client)
    @groups = Groups.new(client)
    @home = Home.new(client)
    @reports = Reports.new(client)
    @search = Search.new(client)
    @server_info = ServerInfo.new(client)
    @sheets = Sheets.new(client)
    @sights = Sights.new(client)
    @token = Token.new(client)
    @templates = Templates.new(client)
    @update_requests = UpdateRequests.new(client)
    @users = Users.new(client)
    @webhooks = Webhooks.new(client)
    @workspaces = Workspaces.new(client)
  end

  def init_retry_logic(max_retry_time, backoff_method)
    retry_opts = {}
    retry_opts[:max_retry_time] = max_retry_time unless max_retry_time.nil?
    retry_opts[:backoff_method] = backoff_method unless backoff_method.nil?

    API::RetryLogic.new(**retry_opts)
  end

  def token_env_var
    ENV['SMARTSHEET_ACCESS_TOKEN']
  end
end

Instance Method Details

#inspectObject



148
149
150
151
152
153
154
155
# File 'lib/smartsheet/client.rb', line 148

def inspect
  methods = (self.public_methods - Object.methods)
                .sort
                .map {|m| ':' + m.to_s}
                .join(', ')

  "#<Smartsheet::Client:#{self.object_id} #{methods}>"
end