Class: Pipekit::Request
- Inherits:
-
Object
- Object
- Pipekit::Request
- Includes:
- HTTParty
- Defined in:
- lib/pipekit/request.rb
Constant Summary collapse
- PIPEDRIVE_URL =
"https://api.pipedrive.com/v1"
Instance Method Summary collapse
- #get(uri, query = {}) ⇒ Object
- #post(uri, body) ⇒ Object
- #put(uri, body) ⇒ Object
-
#search_by_field(type:, field:, value:) ⇒ Object
Public: Pipedrive /searchField API call.
Instance Method Details
#get(uri, query = {}) ⇒ Object
35 36 37 |
# File 'lib/pipekit/request.rb', line 35 def get(uri, query = {}) result_from self.class.get(uri, (query: query)) end |
#post(uri, body) ⇒ Object
43 44 45 |
# File 'lib/pipekit/request.rb', line 43 def post(uri, body) result_from self.class.post(uri, (body: body)) end |
#put(uri, body) ⇒ Object
39 40 41 |
# File 'lib/pipekit/request.rb', line 39 def put(uri, body) result_from self.class.put(uri, (body: body)) end |
#search_by_field(type:, field:, value:) ⇒ Object
Public: Pipedrive /searchField API call.
type - Type of the field:
:person - person fields
:deal - deal fields
field - The name of the field.
If it's the custom field the id of the field should be stored in `config/pipedrive.yml`.
value - The value of the field.
Examples
search_by_field(type: :person, field: :cohort, value: 119)
search_by_field(type: :person, field: :github_username, value: "octocat")
Returns an array of Hashes or nil.
27 28 29 30 31 32 33 |
# File 'lib/pipekit/request.rb', line 27 def search_by_field(type:, field:, value:) = {field_type: "#{type}Field", field_key: config["#{type.to_s.pluralize}_fields"][field], return_item_ids: true} get("/searchResults/field", .merge(term: value)) end |