forked from lounna-team/hubspot-api-ruby
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add some associations code to ASSOCIATION_DEFINITIONS * add patch to connection * create new ticket api file * add some ticket spec * ticket update spec * add task endpoint (get/create * add ticket_properties.rb * drop old ruby versions * replace deprecated Faker::Internet.safe_email by Faker::Internet.email * add missing newlines * update test matrix * rubocop -A * adapt gemfiles * fix actions.yml * nicer ticket_properties_spec.rb * fix ruby versions * add default value to task fields in Task#find * add missing newline * fix spec * dry connection post, put and patch methods * dry connection.modification_query send instead of public_send
- Loading branch information
Showing
24 changed files
with
966 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
gemfiles/active_support_6.0.x.gemfile → gemfiles/active_support_7.2.x.gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
source 'https://rubygems.org' | ||
|
||
gem "activesupport", "~> 6.0.0" | ||
gem "activesupport", "~> 7.2.0" | ||
gemspec path: '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Gem::Specification.new do |s| | ||
s.name = "hubspot-api-ruby" | ||
s.version = "0.16.0" | ||
s.version = "0.17.0" | ||
s.require_paths = ["lib"] | ||
s.authors = ["Jonathan"] | ||
s.email = ["[email protected]"] | ||
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s| | |
"changelog_uri" => "https://github.com/captaincontrat/hubspot-api-ruby/blob/master/History.md" | ||
} | ||
|
||
s.required_ruby_version = ">= 2.7" | ||
s.required_ruby_version = ">= 3.1" | ||
|
||
# Add runtime dependencies here | ||
s.add_runtime_dependency "activesupport", ">= 4.2.2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'hubspot/utils' | ||
|
||
module Hubspot | ||
# | ||
# HubSpot Tasks API | ||
# | ||
# {https://developers.hubspot.com/beta-docs/guides/api/crm/engagements/tasks} | ||
# | ||
class Task | ||
TASKS_PATH = '/crm/v3/objects/tasks' | ||
TASK_PATH = '/crm/v3/objects/tasks/:task_id' | ||
DEFAULT_TASK_FIELDS = 'hs_timestamp,hs_task_body,hubspot_owner_id,hs_task_subject,hs_task_status,hs_task_priority,'\ | ||
'hs_task_type,hs_task_reminders' | ||
|
||
attr_reader :properties, :id | ||
|
||
def initialize(response_hash) | ||
@id = response_hash['id'] | ||
@properties = response_hash['properties'].deep_symbolize_keys | ||
end | ||
|
||
class << self | ||
def create!(params = {}, ticket_id: nil) | ||
associations_hash = { 'associations' => [] } | ||
if ticket_id.present? | ||
associations_hash['associations'] << { | ||
"to": { "id": ticket_id }, | ||
"types": [{ "associationCategory": 'HUBSPOT_DEFINED', | ||
"associationTypeId": Hubspot::Association::ASSOCIATION_DEFINITIONS['Task']['Ticket'] }] | ||
} | ||
end | ||
properties = { hs_task_status: 'NOT_STARTED', hs_task_type: 'TODO' }.merge(params) | ||
post_data = associations_hash.merge({ properties: properties }) | ||
|
||
response = Hubspot::Connection.post_json(TASKS_PATH, params: {}, body: post_data) | ||
new(response) | ||
end | ||
|
||
def find(task_id, properties = DEFAULT_TASK_FIELDS) | ||
response = Hubspot::Connection.get_json(TASK_PATH, { task_id: task_id, | ||
properties: properties }) | ||
new(response) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require 'hubspot/utils' | ||
|
||
module Hubspot | ||
# | ||
# HubSpot Tickets API | ||
# | ||
# {https://developers.hubspot.com/beta-docs/guides/api/crm/objects/tickets} | ||
# | ||
class Ticket | ||
TICKETS_PATH = '/crm/v3/objects/tickets' | ||
TICKET_PATH = '/crm/v3/objects/tickets/:ticket_id' | ||
|
||
attr_reader :properties, :id | ||
|
||
def initialize(response_hash) | ||
@id = response_hash['id'] | ||
@properties = response_hash['properties'].deep_symbolize_keys | ||
end | ||
|
||
class << self | ||
def create!(params = {}, contact_id: nil, company_id: nil, deal_id: nil) | ||
associations_hash = { 'associations' => [] } | ||
if contact_id.present? | ||
associations_hash['associations'] << { | ||
"to": { "id": contact_id }, | ||
"types": [{ "associationCategory": 'HUBSPOT_DEFINED', | ||
"associationTypeId": Hubspot::Association::ASSOCIATION_DEFINITIONS['Ticket']['Contact'] }] | ||
} | ||
end | ||
if company_id.present? | ||
associations_hash['associations'] << { | ||
"to": { "id": company_id }, | ||
"types": [{ "associationCategory": 'HUBSPOT_DEFINED', | ||
"associationTypeId": Hubspot::Association::ASSOCIATION_DEFINITIONS['Ticket']['Company'] }] | ||
} | ||
end | ||
if deal_id.present? | ||
associations_hash['associations'] << { | ||
"to": { "id": deal_id }, | ||
"types": [{ "associationCategory": 'HUBSPOT_DEFINED', | ||
"associationTypeId": Hubspot::Association::ASSOCIATION_DEFINITIONS['Ticket']['Deal'] }] | ||
} | ||
end | ||
post_data = associations_hash.merge({ properties: params }) | ||
|
||
response = Hubspot::Connection.post_json(TICKETS_PATH, params: {}, body: post_data) | ||
new(response) | ||
end | ||
|
||
def update!(id, properties = {}) | ||
request = { properties: properties } | ||
response = Hubspot::Connection.patch_json(TICKET_PATH, params: { ticket_id: id }, body: request) | ||
new(response) | ||
end | ||
|
||
def find(ticket_id) | ||
response = Hubspot::Connection.get_json(TICKET_PATH, { ticket_id: ticket_id }) | ||
new(response) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Hubspot | ||
class TicketProperties < Properties | ||
CREATE_PROPERTY_PATH = '/crm/v3/properties/ticket' | ||
class << self | ||
def create!(params = {}) | ||
superclass.create!(CREATE_PROPERTY_PATH, params) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.