Class: DirectusSDK::PreferencesApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PreferencesApi

Returns a new instance of PreferencesApi.



19
20
21
# File 'lib/directus_sdk/api/preferences_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/directus_sdk/api/preferences_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_preferences(table_id, opts = {}) ⇒ GetPreferences

Returns table preferences

Parameters:

  • table_id

    ID of table to return rows from

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

    the optional parameters

Returns:



28
29
30
31
# File 'lib/directus_sdk/api/preferences_api.rb', line 28

def get_preferences(table_id, opts = {})
  data, _status_code, _headers = get_preferences_with_http_info(table_id, opts)
  return data
end

#get_preferences_with_http_info(table_id, opts = {}) ⇒ Array<(GetPreferences, Fixnum, Hash)>

Returns table preferences

Parameters:

  • table_id

    ID of table to return rows from

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

    the optional parameters

Returns:

  • (Array<(GetPreferences, Fixnum, Hash)>)

    GetPreferences data, response status code and response headers



38
39
40
41
42
43
44
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
# File 'lib/directus_sdk/api/preferences_api.rb', line 38

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

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetPreferences')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#get_preferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_preferences(table_id, opts = {}) ⇒ nil

Update table preferences

Parameters:

  • table_id

    ID of table to return rows from

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

    the optional parameters

Options Hash (opts):

  • :id (String)

    Preference&#39;s Unique Identification number

  • :table_name (String)

    Name of table to add

  • :columns_visible (String)

    List of visible columns, separated by commas

  • :sort (Integer)

    The sort order of the column used to override the column order in the schema

  • :sort_order (String)

    Sort Order (ASC&#x3D;Ascending or DESC&#x3D;Descending)

  • :status (String)

    List of status values. separated by comma

Returns:

  • (nil)


87
88
89
90
# File 'lib/directus_sdk/api/preferences_api.rb', line 87

def update_preferences(table_id, opts = {})
  update_preferences_with_http_info(table_id, opts)
  return nil
end

#update_preferences_with_http_info(table_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update table preferences

Parameters:

  • table_id

    ID of table to return rows from

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

    the optional parameters

Options Hash (opts):

  • :id (String)

    Preference&#39;s Unique Identification number

  • :table_name (String)

    Name of table to add

  • :columns_visible (String)

    List of visible columns, separated by commas

  • :sort (Integer)

    The sort order of the column used to override the column order in the schema

  • :sort_order (String)

    Sort Order (ASC&#x3D;Ascending or DESC&#x3D;Descending)

  • :status (String)

    List of status values. separated by comma

Returns:

  • (Array<(nil, Fixnum, Hash)>)

    nil, response status code and response headers



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

def update_preferences_with_http_info(table_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: PreferencesApi.update_preferences ..."
  end
  # verify the required parameter 'table_id' is set
  if @api_client.config.client_side_validation && table_id.nil?
    fail ArgumentError, "Missing the required parameter 'table_id' when calling PreferencesApi.update_preferences"
  end
  if @api_client.config.client_side_validation && opts[:'sort_order'] && !['ASC', 'DESC'].include?(opts[:'sort_order'])
    fail ArgumentError, 'invalid value for "sort_order", must be one of ASC, DESC'
  end
  # resource path
  local_var_path = "/tables/{tableId}/preferences".sub('{' + 'tableId' + '}', table_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  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/x-www-form-urlencoded'])

  # form parameters
  form_params = {}
  form_params["id"] = opts[:'id'] if !opts[:'id'].nil?
  form_params["table_name"] = opts[:'table_name'] if !opts[:'table_name'].nil?
  form_params["columns_visible"] = opts[:'columns_visible'] if !opts[:'columns_visible'].nil?
  form_params["sort"] = opts[:'sort'] if !opts[:'sort'].nil?
  form_params["sort_order"] = opts[:'sort_order'] if !opts[:'sort_order'].nil?
  form_params["status"] = opts[:'status'] if !opts[:'status'].nil?

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PreferencesApi#update_preferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end