Module: FieldView
- Defined in:
- lib/fieldview.rb,
lib/fieldview/util.rb,
lib/fieldview/field.rb,
lib/fieldview/errors.rb,
lib/fieldview/upload.rb,
lib/fieldview/feature.rb,
lib/fieldview/version.rb,
lib/fieldview/boundary.rb,
lib/fieldview/auth_token.rb,
lib/fieldview/list_object.rb,
lib/fieldview/requestable.rb,
lib/fieldview/fieldview_response.rb
Defined Under Namespace
Classes: AllTokensExpiredError, AuthToken, AuthenticationError, BadRequestError, Boundary, Feature, Field, FieldViewError, FieldViewResponse, InternalServerError, InvalidRequestError, ListObject, PermissionError, RateLimitError, RefreshTokenError, Requestable, ServerBusyError, UnexpectedResponseError, Upload, Util
Constant Summary
collapse
"X-Next-Token"
"X-Http-Request-Id"
"X-Limit"
- VERSION =
'0.0.8'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.api_base ⇒ Object
Returns the value of attribute api_base.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def api_base
@api_base
end
|
.api_version ⇒ Object
Returns the value of attribute api_version.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def api_version
@api_version
end
|
.default_page_limit ⇒ Object
Returns the value of attribute default_page_limit.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def default_page_limit
@default_page_limit
end
|
.max_network_retries ⇒ Object
Returns the value of attribute max_network_retries.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def max_network_retries
@max_network_retries
end
|
.now ⇒ Object
Returns the value of attribute now.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def now
@now
end
|
.oauth_token_base ⇒ Object
Returns the value of attribute oauth_token_base.
32
33
34
|
# File 'lib/fieldview.rb', line 32
def oauth_token_base
@oauth_token_base
end
|
Class Method Details
.client_id ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fieldview.rb', line 66
def client_id
@_client_id ||= nil
unless @_client_id
raise AuthenticationError.new('No client id provided. ' \
'Set your client id using "FieldView.client_id = <CLIENT-ID>". ' \
'This should have been provided to you by a Climate representative. ' \
'This takes the form of "my-client"')
end
return @_client_id
end
|
.client_id=(value) ⇒ Object
76
77
78
|
# File 'lib/fieldview.rb', line 76
def client_id=(value)
@_client_id = value
end
|
.client_secret ⇒ Object
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/fieldview.rb', line 80
def client_secret
@_client_secret ||= nil
unless @_client_secret
raise AuthenticationError.new('No client_secret provided. ' \
'Set your client secret using "FieldView.client_secret = <CLIENT-SECRET>". ' \
'This should have been provided to you by a Climate representative. ' \
'This takes the form of "my-client-fz9900x98-x98908j-jslx"')
end
return @_client_secret
end
|
.client_secret=(value) ⇒ Object
90
91
92
|
# File 'lib/fieldview.rb', line 90
def client_secret=(value)
@_client_secret = value
end
|
.get_now_for_auth_token ⇒ Object
35
36
37
|
# File 'lib/fieldview.rb', line 35
def get_now_for_auth_token
now || Time.now
end
|
.handle_response_error_codes(response) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/fieldview.rb', line 94
def handle_response_error_codes(response)
= response.to_hash
code = response.code.to_i
body = response.body
error = nil
case code
when 503
error = ServerBusyError.new(
"Server Busy", http_status: code, http_body: body,
http_headers: )
when 400, 404
error = InvalidRequestError.new(
"Bad input", http_status: code, http_body: body,
http_headers: )
when 401
error = AuthenticationError.new(
"Unauthorized", http_status: code, http_body: body,
http_headers: )
when 403
error = PermissionError.new(
"Forbidden", http_status: code, http_body: body,
http_headers: )
when 429
error = RateLimitError.new(
"Too many requests", http_status: code, http_body: body,
http_headers: )
when 500
error = InternalServerError.new(
"Internal server error", http_status: code, http_body: body,
http_headers: )
end
if error.nil? then
return
else
error.response = response
raise error
end
end
|
.redirect_uri ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'lib/fieldview.rb', line 53
def redirect_uri
@_redirect_uri ||= nil
unless @_redirect_uri
raise AuthenticationError.new("You must set the redirect uri to your proper server " \
"to get new auth tokens if you haven't set one. " \
"Set your redirect uri using FieldView.redirect_uri = <REDIRECT_URI>")
end
return @_redirect_uri
end
|
.redirect_uri=(value) ⇒ Object
62
63
64
|
# File 'lib/fieldview.rb', line 62
def redirect_uri=(value)
@_redirect_uri = value
end
|
.x_api_key ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fieldview.rb', line 39
def x_api_key
@_x_api_key ||= nil
unless @_x_api_key
raise AuthenticationError.new('No x-api-key provided. ' \
'Set your x-api-key using "FieldView.x_api_key = <X-API-KEY>". ' \
'This should have been provided to you by a Climate representative. ' \
'This takes the form of "my-client"')
end
return @_x_api_key
end
|
.x_api_key=(value) ⇒ Object
49
50
51
|
# File 'lib/fieldview.rb', line 49
def x_api_key=(value)
@_x_api_key = value
end
|