ruby_hubspot 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21cd2b84ae331bcecbb2efcca76b818420ad5bf3519c783134ba18d3dfa38533
4
- data.tar.gz: e7cbd736a5ef3795560e8b98144b3c65bac6857ef2a3592cf8f0655e154a04e9
3
+ metadata.gz: b8af2ad903e1a672868c2f6757a2ab8da3e40e37cbf4ba313d2555b225573b77
4
+ data.tar.gz: ee56a7bfa400e723ee9fa61c213f49aebdf5e0909a7a8c8ddbc1877338827f37
5
5
  SHA512:
6
- metadata.gz: a98ec51d08a95627f0a0e2d6f5983d4ef609277ff2d0cd139c88dac10a5a5d99efb9bdd91c03432324175a10871ad8906dede9b2cd9634116e50032ea131f42e
7
- data.tar.gz: 4bd71dd3cb75fb2c067ff4d55d93d1884a5ddfbf973db56cd0ec467cd38da44db945c44b332090a0e2debd9dd840fd14b5034e41a1168759e88b3e8704ad9b7c
6
+ metadata.gz: 8fd784b6059bc371265e1812d99d49b43d322e496e0f308f976f1748ce69743450accb276ecb458a5ed75a246d82a912dbc6ca4c7e56c316fb7ab04d09cc6f68
7
+ data.tar.gz: a0188d60c29d1642c317b948d0ddbf7f217ec99762054a85d174474ac8f34cb17afb2ee73434d3b3a06d1333c6ed06ef3965464205764d6920866734febaff7a
@@ -1,21 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Companies module
3
+ # Companies module adds methods for Company objects
4
4
  module Companies
5
5
  include Constants
6
6
 
7
+ # returns all companies
7
8
  def all_companies
8
9
  validate_access_token
9
10
 
10
11
  response(GET, ALL_COMPANIES)
11
12
  end
12
13
 
14
+ # creates a company
13
15
  def create_company(**params)
14
16
  validate_access_token
15
17
 
16
18
  response(POST, INDIVIDUAL_COMPANY, params)
17
19
  end
18
20
 
21
+ # shows a company
19
22
  def show_company(**params)
20
23
  validate_access_token
21
24
  id_handler(params[:id])
@@ -23,6 +26,7 @@ module Companies
23
26
  response(GET, individual_company_path(params[:id]))
24
27
  end
25
28
 
29
+ # updates a company
26
30
  def update_company(**params)
27
31
  validate_access_token
28
32
  id_handler(params[:id])
@@ -33,6 +37,7 @@ module Companies
33
37
  response(PUT, individual_company_path(params[:id]), params_to_update)
34
38
  end
35
39
 
40
+ # deletes a company
36
41
  def delete_company(**params)
37
42
  validate_access_token
38
43
  id_handler(params[:id])
@@ -40,6 +45,7 @@ module Companies
40
45
  response(DELETE, individual_company_path(params[:id]))
41
46
  end
42
47
 
48
+ # creates an idintificator
43
49
  def individual_company_path(id)
44
50
  INDIVIDUAL_COMPANY + id.to_s
45
51
  end
@@ -1,25 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Constants module
3
+ # Constants module includes all constants
4
4
  module Constants
5
+ # hubspot api url
5
6
  API_URL = 'https://api.hubapi.com/'
7
+ # content type for request
6
8
  CONTENT_TYPE = 'application/json'
9
+ # authorization key for access
7
10
  AUTHORIZATION_KEY = 'Bearer '
11
+ # method get for request
8
12
  GET = :get
13
+ # method post for request
9
14
  POST = :post
15
+ # method patch for request
10
16
  PATCH = :patch
17
+ # method put for request
11
18
  PUT = :put
19
+ # method delete for request
12
20
  DELETE = :delete
21
+ # hubspot all contacts request path
13
22
  ALL_CONTACTS = 'crm/v4/objects/contacts'
23
+ # hubspot all companies request path
14
24
  ALL_COMPANIES = 'crm/v3/properties/companies'
25
+ # hubspot all deals request path
15
26
  ALL_DEALS = 'crm/v4/objects/deals'
27
+ # hubspot all submitions request path
16
28
  ALL_SUBMITIONS = 'crm/v4/objects/feedback_submissions'
29
+ # hubspot individual contact request path
17
30
  INDIVIDUAL_CONTACT = 'contacts/v1/contact'
31
+ # hubspot individual company request path
18
32
  INDIVIDUAL_COMPANY = 'companies/v2/companies/'
33
+ # hubspot individual deal request path
19
34
  INDIVIDUAL_DEAL = 'deals/v1/deal'
35
+ # hubspot individual sub request path
20
36
  INDIVIDUAL_SUB = 'feedback_submissions/v1/feedback_submission'
37
+ # hubspot create or update request path
21
38
  CREATE_OR_UPDATE = '/createOrUpdate'
39
+ # hubspot vid request path
22
40
  VID = '/vid/'
41
+ # hubspot email request path
23
42
  EMAIL = '/email/'
43
+ # hubspot profile request path
24
44
  PROFILE = '/profile'
25
45
  end
@@ -1,21 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Contacts module
3
+ # Companies module adds methods for Contact objects
4
4
  module Contacts
5
5
  include Constants
6
6
 
7
+ # returns all contacts
7
8
  def all_contacts
8
9
  validate_access_token
9
10
 
10
11
  response(GET, ALL_CONTACTS)
11
12
  end
12
13
 
14
+ # creates a contact
13
15
  def create_contact(**params)
14
16
  validate_access_token
15
17
 
16
18
  response(POST, INDIVIDUAL_CONTACT, params)
17
19
  end
18
20
 
21
+ # creates or updates a contact
19
22
  def create_or_update_contact(**params)
20
23
  validate_access_token
21
24
  email_handler(params[:email])
@@ -23,12 +26,14 @@ module Contacts
23
26
  response(POST, INDIVIDUAL_CONTACT + CREATE_OR_UPDATE + EMAIL + params[:email].to_s, params)
24
27
  end
25
28
 
29
+ # shows a contact
26
30
  def show_contact(**params)
27
31
  validate_access_token
28
32
 
29
33
  response(GET, INDIVIDUAL_CONTACT + find_idintificator(params) + PROFILE)
30
34
  end
31
35
 
36
+ # updates a contact
32
37
  def update_contact(**params)
33
38
  validate_access_token
34
39
 
@@ -38,12 +43,14 @@ module Contacts
38
43
  response(POST, INDIVIDUAL_CONTACT + find_idintificator(params) + PROFILE, params_to_update)
39
44
  end
40
45
 
46
+ # deletes a contact
41
47
  def delete_contact(**params)
42
48
  validate_access_token
43
49
 
44
50
  response(DELETE, INDIVIDUAL_CONTACT + find_idintificator(params))
45
51
  end
46
52
 
53
+ # checks and finds an idintificator
47
54
  def find_idintificator(params)
48
55
  identificator_handler(
49
56
  %i[email id].any? do |key|
@@ -1,26 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Error module
3
+ # Error module adds new error methods
4
4
  module ErrorHandler
5
+ # access token error
5
6
  ACCESS_TOKEN_ERROR = 'Access Token should exist'
7
+ # email error
6
8
  EMAIL_ERROR = 'Email should exist'
9
+ # identificator error
7
10
  IDENTIFICATOR_ERROR = 'Email or id should exist'
11
+ # id error
8
12
  ID_ERROR = 'Id should exist'
9
13
 
10
14
  protected
11
15
 
16
+ # checks access token presence
12
17
  def access_token_handler(access_token)
13
18
  raise ArgumentError, ACCESS_TOKEN_ERROR unless access_token
14
19
  end
15
20
 
21
+ # checks email presence
16
22
  def email_handler(email)
17
23
  raise ArgumentError, EMAIL_ERROR unless email
18
24
  end
19
25
 
26
+ # checks id presence
20
27
  def id_handler(id)
21
28
  raise ArgumentError, ID_ERROR unless id
22
29
  end
23
30
 
31
+ # checks identificator presence
24
32
  def identificator_handler(identificator)
25
33
  raise ArgumentError, IDENTIFICATOR_ERROR unless identificator
26
34
  end
@@ -6,7 +6,7 @@ require_relative 'constants'
6
6
  require_relative 'contacts'
7
7
  require_relative 'companies'
8
8
 
9
- # Hubspot main
9
+ # Hubspot main controls and regulate all methods and constants
10
10
  class Hubspot
11
11
  include ErrorHandler
12
12
  include Constants
@@ -15,10 +15,12 @@ class Hubspot
15
15
 
16
16
  attr_accessor :access_token
17
17
 
18
+ # initializes Hubspot with access token
18
19
  def initialize(access_token:)
19
20
  @access_token = access_token
20
21
  end
21
22
 
23
+ # sends a request to Hubspot with access token and params
22
24
  def request(http_method, path, **params)
23
25
  validate_access_token
24
26
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Version module
3
4
  module RubyHubspot
4
- VERSION = '1.0.1'
5
+ # gem version
6
+ VERSION = '1.0.2'
5
7
  end
data/lib/ruby_hubspot.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Ruby Hubspot includes version and Hubspot class
3
4
  require_relative 'ruby_hubspot/version'
4
5
  require_relative 'ruby_hubspot/hubspot'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_hubspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sofiyareverse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement