Module: SendgridWeb::URL

Included in:
Request
Defined in:
lib/sendgrid_web/utils.rb

Overview

Utility to assemble a URL for Sendgrid.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formatObject

Returns the value of attribute format.



7
8
9
# File 'lib/sendgrid_web/utils.rb', line 7

def format
  @format
end

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/sendgrid_web/utils.rb', line 7

def params
  @params
end

#resourceObject

Returns the value of attribute resource.



7
8
9
# File 'lib/sendgrid_web/utils.rb', line 7

def resource
  @resource
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/sendgrid_web/utils.rb', line 7

def url
  @url
end

#verbObject

Returns the value of attribute verb.



7
8
9
# File 'lib/sendgrid_web/utils.rb', line 7

def verb
  @verb
end

Instance Method Details

#param(param) ⇒ Object

Add or overwrite a param in @params hash. These are passed through to Faraday.



24
25
26
27
# File 'lib/sendgrid_web/utils.rb', line 24

def param(param)
  @params ||= {}
  @params.merge!(param)
end

#url_actionObject

Returns action portion of Sendgrid URL, e.g. “api/resource.verb.format”



15
16
17
18
19
20
# File 'lib/sendgrid_web/utils.rb', line 15

def url_action
  parts = []
  parts << SendgridWeb.api_namespace
  parts << [resource, verb, format].join('.')
  parts.join('/')
end

#with_dateObject

Convenience method to add param with strict Sendgrid requirements.



31
32
33
# File 'lib/sendgrid_web/utils.rb', line 31

def with_date
  param(:date => 1)
end