Class: Patch::PreferencesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/patch_ruby/api/preferences_api.rb

Constant Summary collapse

OPERATIONS =
[
  :create_preference,
  :delete_preference,
  :retrieve_preference,
  :retrieve_preferences,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PreferencesApi

Returns a new instance of PreferencesApi.



26
27
28
# File 'lib/patch_ruby/api/preferences_api.rb', line 26

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



24
25
26
# File 'lib/patch_ruby/api/preferences_api.rb', line 24

def api_client
  @api_client
end

Instance Method Details

#create_preference(create_preference_request = {}, opts = {}) ⇒ PreferenceResponse

creates a project preference Creates a project preference for the given organization. If you have a preference in place, all of your orders will be directed to the project the preference points to.

Parameters:

  • create_preference_request (CreatePreferenceRequest) (defaults to: {})
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



34
35
36
37
38
# File 'lib/patch_ruby/api/preferences_api.rb', line 34

def create_preference(create_preference_request = {}, opts = {})
  _create_preference_request = Patch::CreatePreferenceRequest.new(create_preference_request) 
  data, _status_code, _headers = create_preference_with_http_info(_create_preference_request, opts)
  data
end

#create_preference_with_http_info(create_preference_request, opts = {}) ⇒ Array<(PreferenceResponse, Integer, Hash)>

creates a project preference Creates a project preference for the given organization. If you have a &#x60;preference&#x60; in place, all of your orders will be directed to the project the preference points to.

Parameters:

Returns:

  • (Array<(PreferenceResponse, Integer, Hash)>)

    PreferenceResponse data, response status code and response headers



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
# File 'lib/patch_ruby/api/preferences_api.rb', line 45

def create_preference_with_http_info(create_preference_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PreferencesApi.create_preference ...'
  end
  # verify the required parameter 'create_preference_request' is set
  if @api_client.config.client_side_validation && create_preference_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_preference_request' when calling PreferencesApi.create_preference"
  end
  # resource path
  local_var_path = '/v1/preferences'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_preference_request)

  # return_type
  return_type = opts[:debug_return_type] || 'PreferenceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearer_auth']

  new_options = opts.merge(
    :operation => :"PreferencesApi.create_preference",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#create_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_preference(id, opts = {}) ⇒ PreferenceResponse

Deletes an organization’s preference for a project Deletes the given preference. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



100
101
102
103
104
# File 'lib/patch_ruby/api/preferences_api.rb', line 100

def delete_preference(id, opts = {})
  
  data, _status_code, _headers = delete_preference_with_http_info(id, opts)
  data
end

#delete_preference_with_http_info(id, opts = {}) ⇒ Array<(PreferenceResponse, Integer, Hash)>

Deletes an organization&#39;s preference for a project Deletes the given &#x60;preference&#x60;. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(PreferenceResponse, Integer, Hash)>)

    PreferenceResponse data, response status code and response headers



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
# File 'lib/patch_ruby/api/preferences_api.rb', line 111

def delete_preference_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PreferencesApi.delete_preference ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.delete_preference"
  end
  # resource path
  local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PreferenceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearer_auth']

  new_options = opts.merge(
    :operation => :"PreferencesApi.delete_preference",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#delete_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#retrieve_preference(id, opts = {}) ⇒ PreferenceResponse

Retrieve the preference Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



164
165
166
167
168
# File 'lib/patch_ruby/api/preferences_api.rb', line 164

def retrieve_preference(id, opts = {})
  
  data, _status_code, _headers = retrieve_preference_with_http_info(id, opts)
  data
end

#retrieve_preference_with_http_info(id, opts = {}) ⇒ Array<(PreferenceResponse, Integer, Hash)>

Retrieve the preference Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(PreferenceResponse, Integer, Hash)>)

    PreferenceResponse data, response status code and response headers



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/patch_ruby/api/preferences_api.rb', line 175

def retrieve_preference_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preference ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.retrieve_preference"
  end
  # resource path
  local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PreferenceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearer_auth']

  new_options = opts.merge(
    :operation => :"PreferencesApi.retrieve_preference",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#retrieve_preferences(opts = {}) ⇒ PreferenceListResponse

Retrieves a list of preferences Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

Returns:



228
229
230
231
232
# File 'lib/patch_ruby/api/preferences_api.rb', line 228

def retrieve_preferences(opts = {})
  
  data, _status_code, _headers = retrieve_preferences_with_http_info(opts)
  data
end

#retrieve_preferences_with_http_info(opts = {}) ⇒ Array<(PreferenceListResponse, Integer, Hash)>

Retrieves a list of preferences Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

Returns:

  • (Array<(PreferenceListResponse, Integer, Hash)>)

    PreferenceListResponse data, response status code and response headers



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/patch_ruby/api/preferences_api.rb', line 239

def retrieve_preferences_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preferences ...'
  end
  # resource path
  local_var_path = '/v1/preferences'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PreferenceListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearer_auth']

  new_options = opts.merge(
    :operation => :"PreferencesApi.retrieve_preferences",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end