Class: MailchimpMarketing::FileManagerApi

Inherits:
Object
  • Object
show all
Defined in:
lib/MailchimpMarketing/api/file_manager_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ FileManagerApi

Returns a new instance of FileManagerApi.



19
20
21
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 19

def initialize(api_client)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_folder(body, opts = {}) ⇒ Object

Add folder



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 175

def create_folder(body, opts = {})
  fail ArgumentError, "Missing required param: 'body'" if body.nil?

  query_params = {}
  post_body = @api_client.object_to_http_body(body)

  local_var_path = '/file-manager/folders'
  data = @api_client.call_api(:POST, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#delete_file(file_id, opts = {}) ⇒ Object

Delete file



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 24

def delete_file(file_id, opts = {})
  fail ArgumentError, "Missing required param: 'file_id'" if file_id.nil?

  query_params = {}
  post_body = nil

  local_var_path = '/file-manager/files/{file_id}'.sub('{' + 'file_id' + '}', file_id.to_s)
  data = @api_client.call_api(:DELETE, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#delete_folder(folder_id, opts = {}) ⇒ Object

Delete folder



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 38

def delete_folder(folder_id, opts = {})
  fail ArgumentError, "Missing required param: 'folder_id'" if folder_id.nil?

  query_params = {}
  post_body = nil

  local_var_path = '/file-manager/folders/{folder_id}'.sub('{' + 'folder_id' + '}', folder_id.to_s)
  data = @api_client.call_api(:DELETE, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#files(opts = {}) ⇒ Object

List stored files



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 52

def files(opts = {})
  fail ArgumentError, 'invalid value for "opts[:"count"]", must be smaller than or equal to 1000.' if !opts[:'count'].nil? && opts[:'count'] > 1000
  fail ArgumentError, 'invalid value for "sort_field", must be one of added_date' if opts[:'sort_field'] && !['added_date'].include?(opts[:'sort_field'])
  fail ArgumentError, 'invalid value for "sort_dir", must be one of ASC, DESC' if opts[:'sort_dir'] && !['ASC', 'DESC'].include?(opts[:'sort_dir'])

  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  query_params[:'created_by'] = opts[:'created_by'] if !opts[:'created_by'].nil?
  query_params[:'before_created_at'] = opts[:'before_created_at'] if !opts[:'before_created_at'].nil?
  query_params[:'since_created_at'] = opts[:'since_created_at'] if !opts[:'since_created_at'].nil?
  query_params[:'sort_field'] = opts[:'sort_field'] if !opts[:'sort_field'].nil?
  query_params[:'sort_dir'] = opts[:'sort_dir'] if !opts[:'sort_dir'].nil?
  post_body = nil

  local_var_path = '/file-manager/files'
  data = @api_client.call_api(:GET, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#get_file(file_id, opts = {}) ⇒ Object

Get file



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 78

def get_file(file_id, opts = {})
  fail ArgumentError, "Missing required param: 'file_id'" if file_id.nil?

  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil?
  post_body = nil

  local_var_path = '/file-manager/files/{file_id}'.sub('{' + 'file_id' + '}', file_id.to_s)
  data = @api_client.call_api(:GET, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#get_folder(folder_id, opts = {}) ⇒ Object

Get folder



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 115

def get_folder(folder_id, opts = {})
  fail ArgumentError, "Missing required param: 'folder_id'" if folder_id.nil?

  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil?
  post_body = nil

  local_var_path = '/file-manager/folders/{folder_id}'.sub('{' + 'folder_id' + '}', folder_id.to_s)
  data = @api_client.call_api(:GET, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#list_folders(opts = {}) ⇒ Object

List folders



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 94

def list_folders(opts = {})
  fail ArgumentError, 'invalid value for "opts[:"count"]", must be smaller than or equal to 1000.' if !opts[:'count'].nil? && opts[:'count'] > 1000

  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'created_by'] = opts[:'created_by'] if !opts[:'created_by'].nil?
  query_params[:'before_created_at'] = opts[:'before_created_at'] if !opts[:'before_created_at'].nil?
  query_params[:'since_created_at'] = opts[:'since_created_at'] if !opts[:'since_created_at'].nil?
  post_body = nil

  local_var_path = '/file-manager/folders'
  data = @api_client.call_api(:GET, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#update_file(file_id, body, opts = {}) ⇒ Object

Update file



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 131

def update_file(file_id, body, opts = {})
  fail ArgumentError, "Missing required param: 'file_id'" if file_id.nil?
  fail ArgumentError, "Missing required param: 'body'" if body.nil?

  query_params = {}
  post_body = @api_client.object_to_http_body(body)

  local_var_path = '/file-manager/files/{file_id}'.sub('{' + 'file_id' + '}', file_id.to_s)
  data = @api_client.call_api(:PATCH, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#update_folder(folder_id, body, opts = {}) ⇒ Object

Update folder



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 146

def update_folder(folder_id, body, opts = {})
  fail ArgumentError, "Missing required param: 'folder_id'" if folder_id.nil?
  fail ArgumentError, "Missing required param: 'body'" if body.nil?

  query_params = {}
  post_body = @api_client.object_to_http_body(body)

  local_var_path = '/file-manager/folders/{folder_id}'.sub('{' + 'folder_id' + '}', folder_id.to_s)
  data = @api_client.call_api(:PATCH, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end

#upload(body, opts = {}) ⇒ Object

Add file



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/MailchimpMarketing/api/file_manager_api.rb', line 161

def upload(body, opts = {})
  fail ArgumentError, "Missing required param: 'body'" if body.nil?

  query_params = {}
  post_body = @api_client.object_to_http_body(body)

  local_var_path = '/file-manager/files'
  data = @api_client.call_api(:POST, local_var_path,
    :query_params => query_params,
    :body => post_body)
  return data
end