Class: Clicksign::JsonApi::QueryBuilder
- Inherits:
-
Object
- Object
- Clicksign::JsonApi::QueryBuilder
- Defined in:
- lib/clicksign/json_api/query_builder.rb
Instance Method Summary collapse
- #fields(**types) ⇒ Object
- #filter(**filters) ⇒ Object
- #include(*types) ⇒ Object
-
#initialize ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
- #order(field) ⇒ Object
- #page(number) ⇒ Object
- #per(size) ⇒ Object
- #to_params ⇒ Object
Constructor Details
#initialize ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
6 7 8 |
# File 'lib/clicksign/json_api/query_builder.rb', line 6 def initialize @params = {} end |
Instance Method Details
#fields(**types) ⇒ Object
35 36 37 38 |
# File 'lib/clicksign/json_api/query_builder.rb', line 35 def fields(**types) types.each { |type, list| @params["fields[#{type}]"] = Array(list).join(',') } self end |
#filter(**filters) ⇒ Object
10 11 12 13 |
# File 'lib/clicksign/json_api/query_builder.rb', line 10 def filter(**filters) filters.each { |k, v| @params["filter[#{k}]"] = v } self end |
#include(*types) ⇒ Object
15 16 17 18 |
# File 'lib/clicksign/json_api/query_builder.rb', line 15 def include(*types) @params['include'] = types.join(',') self end |
#order(field) ⇒ Object
20 21 22 23 |
# File 'lib/clicksign/json_api/query_builder.rb', line 20 def order(field) @params['sort'] = field.to_s self end |
#page(number) ⇒ Object
25 26 27 28 |
# File 'lib/clicksign/json_api/query_builder.rb', line 25 def page(number) @params['page[number]'] = number self end |
#per(size) ⇒ Object
30 31 32 33 |
# File 'lib/clicksign/json_api/query_builder.rb', line 30 def per(size) @params['page[size]'] = size self end |
#to_params ⇒ Object
40 41 42 |
# File 'lib/clicksign/json_api/query_builder.rb', line 40 def to_params @params.dup end |