Class: Files::As2Key
- Inherits:
-
Object
- Object
- Files::As2Key
- Defined in:
- lib/files.com/models/as2_key.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - As2 Key ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: as2_partnership_name (required) - string - AS2 Partnership Name.
Instance Method Summary collapse
-
#as2_partnership_name ⇒ Object
string - AS2 Partnership Name.
- #as2_partnership_name=(value) ⇒ Object
-
#created_at ⇒ Object
date-time - AS2 Key created at date/time.
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#fingerprint ⇒ Object
string - Public key fingerprint.
- #fingerprint=(value) ⇒ Object
-
#id ⇒ Object
int64 - AS2 Key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ As2Key
constructor
A new instance of As2Key.
-
#public_key ⇒ Object
string - Actual contents of Public key.
- #public_key=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: as2_partnership_name (required) - string - AS2 Partnership Name.
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
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 = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/as2_key.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/as2_key.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
116 117 118 |
# File 'lib/files.com/models/as2_key.rb', line 116 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - 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.
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/files.com/models/as2_key.rb', line 140 def self.create(params = {}, = {}) 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, = Api.send_request("/as2_keys", :post, params, ) As2Key.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/files.com/models/as2_key.rb', line 165 def self.delete(id, params = {}, = {}) 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, = Api.send_request("/as2_keys/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
175 176 177 |
# File 'lib/files.com/models/as2_key.rb', line 175 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - As2 Key ID.
122 123 124 125 126 127 128 129 130 |
# File 'lib/files.com/models/as2_key.rb', line 122 def self.find(id, params = {}, = {}) 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, = Api.send_request("/as2_keys/#{params[:id]}", :get, params, ) As2Key.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
132 133 134 |
# File 'lib/files.com/models/as2_key.rb', line 132 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
page - int64 - Current page number.
per_page - int64 - 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 112 113 114 |
# File 'lib/files.com/models/as2_key.rb', line 104 def self.list(params = {}, = {}) 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, = Api.send_request("/as2_keys", :get, params, ) response.data.map do |entity_data| As2Key.new(entity_data, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
as2_partnership_name (required) - string - AS2 Partnership Name
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/files.com/models/as2_key.rb', line 153 def self.update(id, params = {}, = {}) 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, = Api.send_request("/as2_keys/#{params[:id]}", :patch, params, ) As2Key.new(response.data, ) end |
Instance Method Details
#as2_partnership_name ⇒ Object
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_at ⇒ Object
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 |
#fingerprint ⇒ Object
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 |
#id ⇒ Object
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_key ⇒ Object
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 |
#save ⇒ Object
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_id ⇒ Object
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 |