Class: Files::WebhookTest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of WebhookTest.



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

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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

Parameters:

url (required) - string - URL for testing the webhook.
method - string - HTTP method(GET or POST).
encoding - string - HTTP encoding method.  Can be JSON, XML, or RAW (form data).
headers - object - Additional request headers.
body - object - Additional body parameters.
raw_body - string - raw body text
file_as_body - boolean - Send the file data as the request body?
file_form_field - string - Send the file data as a named parameter in the request POST body
action - string - action for test body


157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/files.com/models/webhook_test.rb', line 157

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: url must be an String") if params.dig(:url) and !params.dig(:url).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: method must be an String") if params.dig(:method) and !params.dig(:method).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params.dig(:encoding) and !params.dig(:encoding).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: headers must be an Hash") if params.dig(:headers) and !params.dig(:headers).is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: body must be an Hash") if params.dig(:body) and !params.dig(:body).is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: raw_body must be an String") if params.dig(:raw_body) and !params.dig(:raw_body).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: file_form_field must be an String") if params.dig(:file_form_field) and !params.dig(:file_form_field).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
  raise MissingParameterError.new("Parameter missing: url") unless params.dig(:url)

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

Instance Method Details

#actionObject

string - action for test body



130
131
132
# File 'lib/files.com/models/webhook_test.rb', line 130

def action
  @attributes[:action]
end

#action=(value) ⇒ Object



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

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

#bodyObject

object - Additional body parameters.



94
95
96
# File 'lib/files.com/models/webhook_test.rb', line 94

def body
  @attributes[:body]
end

#body=(value) ⇒ Object



98
99
100
# File 'lib/files.com/models/webhook_test.rb', line 98

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

#codeObject

int64 - Status HTTP code



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

def code
  @attributes[:code]
end

#code=(value) ⇒ Object



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

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

#dataObject

Additional data



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

def data
  @attributes[:data]
end

#data=(value) ⇒ Object



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

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

#encodingObject

string - HTTP encoding method. Can be JSON, XML, or RAW (form data).



76
77
78
# File 'lib/files.com/models/webhook_test.rb', line 76

def encoding
  @attributes[:encoding]
end

#encoding=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/webhook_test.rb', line 80

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

#file_as_bodyObject

boolean - Send the file data as the request body?



112
113
114
# File 'lib/files.com/models/webhook_test.rb', line 112

def file_as_body
  @attributes[:file_as_body]
end

#file_as_body=(value) ⇒ Object



116
117
118
# File 'lib/files.com/models/webhook_test.rb', line 116

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

#file_form_fieldObject

string - Send the file data as a named parameter in the request POST body



121
122
123
# File 'lib/files.com/models/webhook_test.rb', line 121

def file_form_field
  @attributes[:file_form_field]
end

#file_form_field=(value) ⇒ Object



125
126
127
# File 'lib/files.com/models/webhook_test.rb', line 125

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

#headersObject

object - Additional request headers.



85
86
87
# File 'lib/files.com/models/webhook_test.rb', line 85

def headers
  @attributes[:headers]
end

#headers=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/webhook_test.rb', line 89

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

#messageObject

string - Error message



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

def message
  @attributes[:message]
end

#message=(value) ⇒ Object



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

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

#methodObject

string - HTTP method(GET or POST).



67
68
69
# File 'lib/files.com/models/webhook_test.rb', line 67

def method
  @attributes[:method]
end

#method=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/webhook_test.rb', line 71

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

#raw_bodyObject

string - raw body text



103
104
105
# File 'lib/files.com/models/webhook_test.rb', line 103

def raw_body
  @attributes[:raw_body]
end

#raw_body=(value) ⇒ Object



107
108
109
# File 'lib/files.com/models/webhook_test.rb', line 107

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

#saveObject



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

def save
  if @attributes[:id]
    raise NotImplementedError.new("The WebhookTest object doesn't support updates.")
  else
    new_obj = WebhookTest.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#statusObject

string - Status message



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

def status
  @attributes[:status]
end

#status=(value) ⇒ Object



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

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

#successObject

boolean - The success status of the webhook test



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

def success
  @attributes[:success]
end

#success=(value) ⇒ Object



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

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

#urlObject

string - URL for testing the webhook.



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

def url
  @attributes[:url]
end

#url=(value) ⇒ Object



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

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