Class: Smartsheet::API::EndpointSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/smartsheet/api/endpoint_spec.rb

Overview

Specification for a single endpoint's configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, url, **spec) ⇒ EndpointSpec



27
28
29
30
31
# File 'lib/smartsheet/api/endpoint_spec.rb', line 27

def initialize(method, url, **spec)
  @method = method
  @url_segments = url
  @spec = spec
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/smartsheet/api/endpoint_spec.rb', line 7

def method
  @method
end

#specObject (readonly)

Returns the value of attribute spec.



7
8
9
# File 'lib/smartsheet/api/endpoint_spec.rb', line 7

def spec
  @spec
end

#url_segmentsObject (readonly)

Returns the value of attribute url_segments.



7
8
9
# File 'lib/smartsheet/api/endpoint_spec.rb', line 7

def url_segments
  @url_segments
end

Instance Method Details

#headersObject



49
50
51
# File 'lib/smartsheet/api/endpoint_spec.rb', line 49

def headers
  spec.key?(:headers) ? spec[:headers] : {}
end

#requires_auth?Boolean



33
34
35
# File 'lib/smartsheet/api/endpoint_spec.rb', line 33

def requires_auth?
  !spec.key?(:no_auth)
end

#requires_body?Boolean



37
38
39
# File 'lib/smartsheet/api/endpoint_spec.rb', line 37

def requires_body?
  spec.key? :body_type
end

#sending_file?Boolean



41
42
43
# File 'lib/smartsheet/api/endpoint_spec.rb', line 41

def sending_file?
  requires_body? && spec[:body_type] == :file
end

#sending_json?Boolean



45
46
47
# File 'lib/smartsheet/api/endpoint_spec.rb', line 45

def sending_json?
  requires_body? && spec[:body_type] == :json
end