Class: Files::As2Partner

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of As2Partner.



7
8
9
10
# File 'lib/files.com/models/as2_partner.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_partner.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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



118
119
120
# File 'lib/files.com/models/as2_partner.rb', line 118

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

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

Parameters:

name (required) - string - AS2 Name
uri (required) - string - URL base for AS2 responses
public_certificate (required) - string
as2_station_id (required) - int64 - Id of As2Station for this partner


143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/files.com/models/as2_partner.rb', line 143

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

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

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



174
175
176
177
178
179
180
181
182
# File 'lib/files.com/models/as2_partner.rb', line 174

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_partners/#{params[:id]}", :delete, params, options)
  response.data
end

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



184
185
186
# File 'lib/files.com/models/as2_partner.rb', line 184

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

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

Parameters:

id (required) - int64 - As2 Partner ID.


124
125
126
127
128
129
130
131
132
# File 'lib/files.com/models/as2_partner.rb', line 124

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_partners/#{params[:id]}", :get, params, options)
  As2Partner.new(response.data, options)
end

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



134
135
136
# File 'lib/files.com/models/as2_partner.rb', line 134

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

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

Parameters:

cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).


109
110
111
112
113
114
115
116
# File 'lib/files.com/models/as2_partner.rb', line 109

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

  List.new(As2Partner, params) do
    Api.send_request("/as2_partners", :get, params, options)
  end
end

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

Parameters:

name - string - AS2 Name
uri - string - URL base for AS2 responses
public_certificate - string


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

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: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: uri must be an String") if params.dig(:uri) and !params.dig(:uri).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: public_certificate must be an String") if params.dig(:public_certificate) and !params.dig(:public_certificate).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

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

Instance Method Details

#as2_station_idObject

int64 - Id of the AS2 Station associated with this partner.



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

def as2_station_id
  @attributes[:as2_station_id]
end

#as2_station_id=(value) ⇒ Object



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

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

#delete(params = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/files.com/models/as2_partner.rb', line 83

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_partners/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



93
94
95
# File 'lib/files.com/models/as2_partner.rb', line 93

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

#idObject

int64 - Id of the AS2 Partner.



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

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



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

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

#nameObject

string - The partner’s formal AS2 name.



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

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/as2_partner.rb', line 35

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

#public_certificateObject

string



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

def public_certificate
  @attributes[:public_certificate]
end

#public_certificate=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/as2_partner.rb', line 62

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

#public_certificate_md5Object

string - MD5 hash of public certificate used for message security.



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

def public_certificate_md5
  @attributes[:public_certificate_md5]
end

#public_certificate_md5=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/as2_partner.rb', line 53

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

#saveObject



97
98
99
100
101
102
103
104
# File 'lib/files.com/models/as2_partner.rb', line 97

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

#update(params = {}) ⇒ Object

Parameters:

name - string - AS2 Name
uri - string - URL base for AS2 responses
public_certificate - string


70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/files.com/models/as2_partner.rb', line 70

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: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: uri must be an String") if params.dig(:uri) and !params.dig(:uri).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: public_certificate must be an String") if params.dig(:public_certificate) and !params.dig(:public_certificate).is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

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

#uriObject

string - Public URI for sending AS2 message to.



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

def uri
  @attributes[:uri]
end

#uri=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/as2_partner.rb', line 44

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