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
use_dedicated_ips - boolean - Use dedicated IPs for sending the webhook?


169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/files.com/models/webhook_test.rb', line 169

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: url must be an String") if params[:url] and !params[:url].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: method must be an String") if params[:method] and !params[:method].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params[:encoding] and !params[:encoding].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: headers must be an Hash") if params[:headers] and !params[:headers].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: body must be an Hash") if params[:body] and !params[:body].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: raw_body must be an String") if params[:raw_body] and !params[:raw_body].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: file_form_field must be an String") if params[:file_form_field] and !params[:file_form_field].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params[:action] and !params[:action].is_a?(String)
  raise MissingParameterError.new("Parameter missing: url") unless params[: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

Auto - 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



147
148
149
150
151
152
153
154
155
156
# File 'lib/files.com/models/webhook_test.rb', line 147

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

  @attributes = new_obj.attributes
  true
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

#use_dedicated_ipsObject

boolean - Use dedicated IPs for sending the webhook?



139
140
141
# File 'lib/files.com/models/webhook_test.rb', line 139

def use_dedicated_ips
  @attributes[:use_dedicated_ips]
end

#use_dedicated_ips=(value) ⇒ Object



143
144
145
# File 'lib/files.com/models/webhook_test.rb', line 143

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