Class: Files::As2Key

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/as2_key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ As2Key

Returns a new instance of As2Key.



7
8
9
10
# File 'lib/files.com/models/as2_key.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/as2_key.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/as2_key.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



113
114
115
# File 'lib/files.com/models/as2_key.rb', line 113

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - integer - User ID.  Provide a value of `0` to operate the current session's user.
as2_partnership_name (required) - string - AS2 Partnership Name
public_key (required) - string - Actual contents of Public key.


137
138
139
140
141
142
143
144
145
146
# File 'lib/files.com/models/as2_key.rb', line 137

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: as2_partnership_name must be an String") if params.dig(:as2_partnership_name) and !params.dig(:as2_partnership_name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: public_key must be an String") if params.dig(:public_key) and !params.dig(:public_key).is_a?(String)
  raise MissingParameterError.new("Parameter missing: as2_partnership_name") unless params.dig(:as2_partnership_name)
  raise MissingParameterError.new("Parameter missing: public_key") unless params.dig(:public_key)

  response, options = Api.send_request("/as2_keys", :post, params, options)
  As2Key.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/files.com/models/as2_key.rb', line 162

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/as2_keys/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



172
173
174
# File 'lib/files.com/models/as2_key.rb', line 172

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - integer - As2 Key ID.


119
120
121
122
123
124
125
126
127
# File 'lib/files.com/models/as2_key.rb', line 119

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, options = Api.send_request("/as2_keys/#{params[:id]}", :get, params, options)
  As2Key.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



129
130
131
# File 'lib/files.com/models/as2_key.rb', line 129

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

user_id - integer - User ID.  Provide a value of `0` to operate the current session's user.
page - integer - Current page number.
per_page - integer - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.


104
105
106
107
108
109
110
111
# File 'lib/files.com/models/as2_key.rb', line 104

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)

  response, options = Api.send_request("/as2_keys", :get, params, options)
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

as2_partnership_name (required) - string - AS2 Partnership Name


150
151
152
153
154
155
156
157
158
159
160
# File 'lib/files.com/models/as2_key.rb', line 150

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: as2_partnership_name must be an String") if params.dig(:as2_partnership_name) and !params.dig(:as2_partnership_name).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
  raise MissingParameterError.new("Parameter missing: as2_partnership_name") unless params.dig(:as2_partnership_name)

  response, options = Api.send_request("/as2_keys/#{params[:id]}", :patch, params, options)
  As2Key.new(response.data, options)
end

Instance Method Details

#as2_partnership_nameObject

string - AS2 Partnership Name



22
23
24
# File 'lib/files.com/models/as2_key.rb', line 22

def as2_partnership_name
  @attributes[:as2_partnership_name]
end

#as2_partnership_name=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/as2_key.rb', line 26

def as2_partnership_name=(value)
  @attributes[:as2_partnership_name] = value
end

#created_atObject

date-time - AS2 Key created at date/time



31
32
33
# File 'lib/files.com/models/as2_key.rb', line 31

def created_at
  @attributes[:created_at]
end

#delete(params = {}) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/files.com/models/as2_key.rb', line 76

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/as2_keys/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



86
87
88
# File 'lib/files.com/models/as2_key.rb', line 86

def destroy(params = {})
  delete(params)
end

#fingerprintObject

string - Public key fingerprint



36
37
38
# File 'lib/files.com/models/as2_key.rb', line 36

def fingerprint
  @attributes[:fingerprint]
end

#fingerprint=(value) ⇒ Object



40
41
42
# File 'lib/files.com/models/as2_key.rb', line 40

def fingerprint=(value)
  @attributes[:fingerprint] = value
end

#idObject

int64 - AS2 Key ID



13
14
15
# File 'lib/files.com/models/as2_key.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/as2_key.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#public_keyObject

string - Actual contents of Public key.



54
55
56
# File 'lib/files.com/models/as2_key.rb', line 54

def public_key
  @attributes[:public_key]
end

#public_key=(value) ⇒ Object



58
59
60
# File 'lib/files.com/models/as2_key.rb', line 58

def public_key=(value)
  @attributes[:public_key] = value
end

#saveObject



90
91
92
93
94
95
96
97
# File 'lib/files.com/models/as2_key.rb', line 90

def save
  if @attributes[:id]
    update(@attributes)
  else
    new_obj = As2Key.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#update(params = {}) ⇒ Object

Parameters:

as2_partnership_name (required) - string - AS2 Partnership Name


64
65
66
67
68
69
70
71
72
73
74
# File 'lib/files.com/models/as2_key.rb', line 64

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: as2_partnership_name must be an String") if params.dig(:as2_partnership_name) and !params.dig(:as2_partnership_name).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
  raise MissingParameterError.new("Parameter missing: as2_partnership_name") unless params.dig(:as2_partnership_name)

  Api.send_request("/as2_keys/#{@attributes[:id]}", :patch, params, @options)
end

#user_idObject

int64 - User ID. Provide a value of ‘0` to operate the current session’s user.



45
46
47
# File 'lib/files.com/models/as2_key.rb', line 45

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



49
50
51
# File 'lib/files.com/models/as2_key.rb', line 49

def user_id=(value)
  @attributes[:user_id] = value
end