Class: FieldView::Field
- Inherits:
-
Requestable
- Object
- Requestable
- FieldView::Field
- Defined in:
- lib/fieldview/field.rb
Constant Summary collapse
- PATH =
"fields"
Instance Attribute Summary collapse
-
#boundary_id ⇒ Object
Returns the value of attribute boundary_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Requestable
Class Method Summary collapse
Instance Method Summary collapse
- #boundary ⇒ Object
-
#initialize(json_object, auth_token = nil) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(json_object, auth_token = nil) ⇒ Field
Returns a new instance of Field.
7 8 9 10 11 12 |
# File 'lib/fieldview/field.rb', line 7 def initialize(json_object, auth_token = nil) self.id = json_object[:id] self.name = json_object[:name] self.boundary_id = json_object[:boundaryId] super(auth_token) end |
Instance Attribute Details
#boundary_id ⇒ Object
Returns the value of attribute boundary_id.
6 7 8 |
# File 'lib/fieldview/field.rb', line 6 def boundary_id @boundary_id end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/fieldview/field.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/fieldview/field.rb', line 5 def name @name end |
Class Method Details
.list(auth_token, limit: nil, next_token: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fieldview/field.rb', line 22 def self.list(auth_token, limit: nil, next_token: nil) limit ||= FieldView.default_page_limit response = auth_token.execute_request!(:get, PATH, headers: { FieldView::NEXT_TOKEN_HEADER_KEY => next_token, FieldView::PAGE_LIMIT_HEADER_KEY => limit }) Util.verify_response_with_code("Field list", response, 200, 206, 304) next_token = response.http_headers[FieldView::NEXT_TOKEN_HEADER_KEY] case response.http_status when 200, 206 # 206: Partial result, will have more data # 200: When all the results were in the list return_data = response.data[:results] when 304 # 304: Nothing modified since last request return_data = [] end return ListObject.new( self, auth_token, return_data.collect { |i| Field.new(i, auth_token) }, response.http_status, next_token: next_token, limit: limit) end |
.retrieve(auth_token, id) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/fieldview/field.rb', line 14 def self.retrieve(auth_token, id) response = auth_token.execute_request!(:get, "#{PATH}/#{id}") Util.verify_response_with_code("Field retrieve", response, 200) return new(response.data, auth_token) end |
Instance Method Details
#boundary ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/fieldview/field.rb', line 53 def boundary @boundary ||= nil if @boundary.nil? @boundary = Boundary.new(self.auth_token.execute_request!(:get, "boundaries/#{self.boundary_id}").data) end return @boundary end |