hubspot-ruby 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hubspot-ruby.gemspec +2 -2
- data/lib/hubspot-ruby.rb +1 -0
- data/lib/hubspot/company.rb +3 -2
- data/lib/hubspot/connection.rb +28 -0
- data/lib/hubspot/contact.rb +2 -2
- data/lib/hubspot/deal.rb +2 -1
- data/lib/hubspot/file.rb +23 -0
- data/lib/hubspot/form.rb +5 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a0aeec54b2d900dfb6bd1d3e19521c7119eefa45be6ee235239845f6773379
|
4
|
+
data.tar.gz: 93c2715fcb9421d58b5bb2d4ac91af211a733ca0b3e8a33a152ccc529cfd6383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22eae174071b14d21fb83859c2e463bec5b14605fbbea1659241bdb990ba8e5dd972ebaff048c52520fc23d4a61bcd024b3932acd475e3568986dff40b656dfe
|
7
|
+
data.tar.gz: c0a85d5cc804e4b84378039f235ba5e8aa9eeab6ea8bbeb3d274c13f261f1517391c508172cf8e5c7d02dd66d521088b870a28b753e41b840a6d3801de2b3a65
|
data/hubspot-ruby.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "hubspot-ruby"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.9.0"
|
4
4
|
s.require_paths = ["lib"]
|
5
|
-
s.authors = ["Andrew DiMichele", "Chris Bisnett"]
|
5
|
+
s.authors = ["Andrew DiMichele", "Chris Bisnett", "Vladislav Ermolkin"]
|
6
6
|
s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
|
7
7
|
s.licenses = ["MIT"]
|
8
8
|
s.files = [".rspec", "Gemfile", "Guardfile", "LICENSE.txt", "README.md", "RELEASING.md", "Rakefile", "hubspot-ruby.gemspec"]
|
data/lib/hubspot-ruby.rb
CHANGED
data/lib/hubspot/company.rb
CHANGED
@@ -151,7 +151,7 @@ module Hubspot
|
|
151
151
|
end
|
152
152
|
Hubspot::Connection.post_json(BATCH_UPDATE_PATH, params: {}, body: query)
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
# Adds contact to a company
|
156
156
|
# {http://developers.hubspot.com/docs/methods/companies/add_contact_to_company}
|
157
157
|
# @param company_vid [Integer] The ID of a company to add a contact to
|
@@ -171,7 +171,8 @@ module Hubspot
|
|
171
171
|
attr_reader :vid, :name
|
172
172
|
|
173
173
|
def initialize(response_hash)
|
174
|
-
|
174
|
+
props = response_hash['properties'] || {}
|
175
|
+
@properties = Hubspot::Utils.properties_to_hash(props)
|
175
176
|
@vid = response_hash["companyId"]
|
176
177
|
@name = @properties.try(:[], "name")
|
177
178
|
end
|
data/lib/hubspot/connection.rb
CHANGED
@@ -128,4 +128,32 @@ module Hubspot
|
|
128
128
|
post(url, body: opts[:body], headers: { 'Content-Type' => 'application/x-www-form-urlencoded' })
|
129
129
|
end
|
130
130
|
end
|
131
|
+
|
132
|
+
class FilesConnection < Connection
|
133
|
+
follow_redirects true
|
134
|
+
|
135
|
+
class << self
|
136
|
+
def get(path, opts)
|
137
|
+
url = generate_url(path, opts)
|
138
|
+
response = super(url, read_timeout: read_timeout(opts), open_timeout: open_timeout(opts))
|
139
|
+
log_request_and_response url, response
|
140
|
+
raise(Hubspot::RequestError.new(response)) unless response.success?
|
141
|
+
response.parsed_response
|
142
|
+
end
|
143
|
+
|
144
|
+
def post(path, opts)
|
145
|
+
url = generate_url(path, opts[:params])
|
146
|
+
response = super(
|
147
|
+
url,
|
148
|
+
body: opts[:body],
|
149
|
+
headers: { 'Content-Type' => 'multipart/form-data' },
|
150
|
+
read_timeout: read_timeout(opts), open_timeout: open_timeout(opts)
|
151
|
+
)
|
152
|
+
log_request_and_response url, response, opts[:body]
|
153
|
+
raise(Hubspot::RequestError.new(response)) unless response.success?
|
154
|
+
|
155
|
+
response
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
131
159
|
end
|
data/lib/hubspot/contact.rb
CHANGED
@@ -169,8 +169,8 @@ module Hubspot
|
|
169
169
|
attr_reader :is_contact, :list_memberships
|
170
170
|
|
171
171
|
def initialize(response_hash)
|
172
|
-
props = response_hash['properties']
|
173
|
-
@properties = Hubspot::Utils.properties_to_hash(props)
|
172
|
+
props = response_hash['properties'] || {}
|
173
|
+
@properties = Hubspot::Utils.properties_to_hash(props)
|
174
174
|
@is_contact = response_hash["is-contact"]
|
175
175
|
@list_memberships = response_hash["list-memberships"] || []
|
176
176
|
@vid = response_hash['vid']
|
data/lib/hubspot/deal.rb
CHANGED
@@ -22,11 +22,12 @@ module Hubspot
|
|
22
22
|
attr_reader :vids
|
23
23
|
|
24
24
|
def initialize(response_hash)
|
25
|
+
props = response_hash['properties'] || {}
|
26
|
+
@properties = Hubspot::Utils.properties_to_hash(props)
|
25
27
|
@portal_id = response_hash["portalId"]
|
26
28
|
@deal_id = response_hash["dealId"]
|
27
29
|
@company_ids = response_hash["associations"]["associatedCompanyIds"]
|
28
30
|
@vids = response_hash["associations"]["associatedVids"]
|
29
|
-
@properties = Hubspot::Utils.properties_to_hash(response_hash["properties"])
|
30
31
|
end
|
31
32
|
|
32
33
|
class << self
|
data/lib/hubspot/file.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Hubspot
|
2
|
+
class File
|
3
|
+
UPLOAD_FILE_PATH = '/filemanager/api/v2/files'
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def upload(file, params)
|
7
|
+
query = {
|
8
|
+
overwrite: params['overwrite'] || false,
|
9
|
+
hidden: params['hidden'] || false
|
10
|
+
}
|
11
|
+
options = {
|
12
|
+
multipart:
|
13
|
+
[
|
14
|
+
{ name: 'files', contents: file },
|
15
|
+
{ name: 'file_names', contents: params['file_names'] },
|
16
|
+
{ name: 'folder_paths', contents: params['folder_paths'] }
|
17
|
+
]
|
18
|
+
}
|
19
|
+
Hubspot::FilesConnection.post(UPLOAD_FILE_PATH, params: query, body: options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/hubspot/form.rb
CHANGED
@@ -28,6 +28,11 @@ module Hubspot
|
|
28
28
|
response = Hubspot::Connection.get_json(FORM_PATH, { form_guid: guid })
|
29
29
|
new(response)
|
30
30
|
end
|
31
|
+
|
32
|
+
def upload_file(uri)
|
33
|
+
path = URI::parse(uri).request_uri
|
34
|
+
Hubspot::FilesConnection.get(path, {})
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
attr_reader :guid
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew DiMichele
|
8
8
|
- Chris Bisnett
|
9
|
+
- Vladislav Ermolkin
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2019-
|
13
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: activesupport
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- lib/hubspot/deprecator.rb
|
223
224
|
- lib/hubspot/engagement.rb
|
224
225
|
- lib/hubspot/exceptions.rb
|
226
|
+
- lib/hubspot/file.rb
|
225
227
|
- lib/hubspot/form.rb
|
226
228
|
- lib/hubspot/oauth.rb
|
227
229
|
- lib/hubspot/owner.rb
|
@@ -278,8 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
280
|
- !ruby/object:Gem::Version
|
279
281
|
version: '0'
|
280
282
|
requirements: []
|
281
|
-
|
282
|
-
rubygems_version: 2.7.6
|
283
|
+
rubygems_version: 3.0.6
|
283
284
|
signing_key:
|
284
285
|
specification_version: 4
|
285
286
|
summary: hubspot-ruby is a wrapper for the HubSpot REST API
|