help_scout-sdk 1.1.0 → 3.0.1

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: 9d4c58f9f96b57b2d1bbc0cd69ad741ffa6201244861167992e8212901d491d2
4
- data.tar.gz: 055c66adf697283a7836ce6fdb91156cea27ea1cddf0fc6f8b2c05c07ed174a8
3
+ metadata.gz: 4286a555cb8b028bcc762b8152d44d13698b8e4f3fe9edc546ba459ba3b9ef70
4
+ data.tar.gz: f54e8cce71dccf0ab9e79b2dbe1a3e212c3d58d70db03d10ec4b27e98b1dc410
5
5
  SHA512:
6
- metadata.gz: 2058da0b726acce0ef9993b40e827bb2be27f2947c78dfcb57216e51acb3fbcd4969b86a658e621e1bd63c1e6410f291a55cb2aaa03fd446374208e2376eeed0
7
- data.tar.gz: 10b8bbca725910b62a0b3120247506d50b8c7e3f34ed50a39ae2ddeb340d9081803b66d2649e9a9b410de4d1af2eb346372f3b96bcb6e7543f38e6f7c790f163
6
+ metadata.gz: 4cd56f581e3c66a2602e2f26071befb87b3f6546f53848415c6a5d357e6373767065e681802936b73a81e092bd712bc6434caa7f976dd422004b1b2cd9c1f618
7
+ data.tar.gz: 38ada331bd5a25454540ec4a5f436c16c2ba6955a2049b62cf1a53e90040fe4dbf0f2f1ff0d5a510dbbc5697e111574ec63f16c3215d1f03a7ef4d288db0557e
data/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ ### master (unreleased)
2
+
3
+ ## 3.0.0 / 2024-03-14
4
+
5
+ Breaking Changes:
6
+
7
+ * Upgrades Faraday dependency to 2.9 which makes it compatible with Ruby 3.x
8
+ However, Faraday does not support Ruby 2.x on this version.
9
+ ([#30](https://github.com/taxjar/help_scout-sdk/pull/30))
10
+
11
+ ### 2.0.0 / 2019-07-19
12
+
13
+ Breaking Changes:
14
+
15
+ * Removes HelpScout::Configuration#access_token and writer to avoid multiple sources
16
+ of truth for access token values ([#14](https://github.com/taxjar/help_scout-sdk/pull/14))
17
+
18
+ Enhancements:
19
+
20
+ * Adds support for `HelpScout::Thread.create`, `HelpScout::Thread.get`, and
21
+ `HelpScout::Thread#update` (Justin White, [#13](https://github.com/taxjar/help_scout-sdk/pull/13))
22
+
23
+ ### 1.1.0 / 2019-06-20
24
+
25
+ ### 1.0.2 / 2019-06-07
26
+
27
+ ### 1.0.1 / 2019-06-07
28
+
29
+ ### 1.0.0 / 2019-06-05
30
+
31
+ Breaking Changes:
32
+
33
+ * Drops support for the Mailbox 1.0 API ([#2](https://github.com/taxjar/help_scout-sdk/pull/2))
34
+
35
+ Enhancements:
36
+
37
+ * Updated to support the Mailbox 2.0 API ([#2](https://github.com/taxjar/help_scout-sdk/pull/2))
data/README.md CHANGED
@@ -23,8 +23,7 @@ And then execute:
23
23
  | :------------------------- | :--: | :--: | :-----: | :----: | :-----: |
24
24
  | Attachment | ❌ | ❌ | ✅ | ❌ | ❌ |
25
25
  | Conversations | ✅ | ✅ | ✅ | ✅ | ❌ |
26
- | Conversation::Threads | | | | | |
27
- | Conversation::ThreadSource | ❌ | ❌ | ❌ | ❌ | ❌ |
26
+ | Conversation::Threads | | | | | |
28
27
  | Customers | ✅ | ✅ | ❌ | ❌ | ❌ |
29
28
  | Notes | ❌ | ❌ | ❌ | ❌ | ❌ |
30
29
  | Mailboxes | ✅ | ✅ | ➖ | ➖ | ➖ |
@@ -50,8 +49,6 @@ And then execute:
50
49
  HelpScout.configure do |config|
51
50
  config.app_id = ENV["HELP_SCOUT_APP_ID"]
52
51
  config.app_secret = ENV["HELP_SCOUT_APP_SECRET"]
53
-
54
- config.access_token = HelpScout::API::AccessToken.create
55
52
  end
56
53
  ```
57
54
 
@@ -86,6 +83,19 @@ mailbox.fields
86
83
  mailbox.folders
87
84
  ```
88
85
 
86
+ ### Threads
87
+
88
+ [Documentation Link](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list/)
89
+
90
+ ```ruby
91
+ conversation = HelpScout::Conversation.list.first
92
+ new_thread = HelpScout::Thread.create(conversation.id, "notes", { text: 'Hello, world!' })
93
+ threads = HelpScout::Thread.list(conversation.id)
94
+ latest_thread = threads.first
95
+ latest_thread.update("replace", "/text", "Updating a threads text.")
96
+ modified_thread = HelpScout::Thread.get(conversation.id, latest_thread.id)
97
+ ```
98
+
89
99
  ### Users
90
100
 
91
101
  [Documentation Link](https://developer.helpscout.com/mailbox-api/endpoints/users/list/)
data/bin/console CHANGED
@@ -11,7 +11,6 @@ HelpScout.configure do |config|
11
11
  config.app_id = ENV.fetch('HELP_SCOUT_APP_ID')
12
12
  config.app_secret = ENV.fetch('HELP_SCOUT_APP_SECRET')
13
13
  config.default_mailbox = ENV.fetch('HELP_SCOUT_DEFAULT_MAILBOX')
14
- config.access_token = ENV.fetch('HELP_SCOUT_ACCESS_TOKEN', nil)
15
14
  end
16
15
 
17
16
  begin
@@ -31,9 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_dependency 'activesupport'
34
- spec.add_dependency 'faraday', '~> 0.10'
35
- spec.add_dependency 'faraday_middleware', '>= 0.10.1', '< 1.0'
36
- spec.required_ruby_version = '>= 2.3'
34
+ spec.add_dependency 'faraday', '2.9.0'
35
+ spec.required_ruby_version = '>= 3.0'
37
36
 
38
37
  spec.add_development_dependency 'awesome_print', '~> 1.8'
39
38
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -16,7 +16,7 @@ module HelpScout
16
16
  end
17
17
 
18
18
  def refresh!
19
- return HelpScout.api.access_token unless HelpScout.access_token.nil? || HelpScout.access_token.stale?
19
+ return HelpScout.access_token unless HelpScout.access_token.nil? || HelpScout.access_token.stale?
20
20
 
21
21
  HelpScout.api.access_token = create
22
22
  end
@@ -13,7 +13,7 @@ module HelpScout
13
13
  @_connection ||= build_connection.tap do |conn|
14
14
  if authorize?
15
15
  HelpScout::API::AccessToken.refresh!
16
- conn.authorization(:Bearer, access_token) if access_token
16
+ conn.request(:authorization, 'Bearer', access_token) if access_token
17
17
  end
18
18
  end
19
19
  end
@@ -3,17 +3,10 @@
3
3
  module HelpScout
4
4
  class Configuration
5
5
  attr_accessor :app_id, :app_secret, :default_mailbox, :token_cache
6
- attr_reader :access_token
7
6
  attr_writer :token_cache_key
8
7
 
9
8
  DEFAULT_CACHE_KEY = 'help_scout_token_cache'
10
9
 
11
- def access_token=(token_value)
12
- return unless token_value
13
-
14
- @access_token = HelpScout::API::AccessToken.new(access_token: token_value)
15
- end
16
-
17
10
  def token_cache_key
18
11
  return @token_cache_key if defined?(@token_cache_key)
19
12
 
@@ -3,12 +3,33 @@
3
3
  module HelpScout
4
4
  class Thread < HelpScout::Base
5
5
  class << self
6
+ def create(conversation_id, thread_type, params)
7
+ HelpScout.api.post(
8
+ create_path(conversation_id, thread_type),
9
+ HelpScout::Util.camelize_keys(params)
10
+ )
11
+ true
12
+ end
13
+
6
14
  def list(conversation_id, page: nil)
7
- HelpScout.api.get(list_path(conversation_id), page: page).embedded_list.map { |details| new details }
15
+ HelpScout.api.get(
16
+ list_path(conversation_id), page: page
17
+ ).embedded_list.map { |details| new details.merge(conversation_id: conversation_id) }
18
+ end
19
+
20
+ def get(conversation_id, thread_id)
21
+ threads = list(conversation_id)
22
+ thread_id = thread_id.to_i
23
+
24
+ threads.find { |thread| thread.id == thread_id }
8
25
  end
9
26
 
10
27
  private
11
28
 
29
+ def create_path(conversation_id, thread_type)
30
+ "conversations/#{conversation_id}/#{thread_type}"
31
+ end
32
+
12
33
  def list_path(conversation_id)
13
34
  "conversations/#{conversation_id}/threads"
14
35
  end
@@ -32,6 +53,7 @@ module HelpScout
32
53
  created_at
33
54
  opened_at
34
55
  attachments
56
+ conversation_id
35
57
  ].freeze
36
58
 
37
59
  attr_accessor(*BASIC_ATTRIBUTES)
@@ -46,5 +68,15 @@ module HelpScout
46
68
 
47
69
  @hrefs = HelpScout::Util.map_links(params.fetch(:_links, []))
48
70
  end
71
+
72
+ def conversation
73
+ @_conversation ||= HelpScout::Conversation.get(conversation_id)
74
+ end
75
+
76
+ def update(operation, path, value = nil)
77
+ update_path = "conversations/#{conversation_id}/threads/#{id}"
78
+ HelpScout.api.patch(update_path, op: operation, path: path, value: value)
79
+ true
80
+ end
49
81
  end
50
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelpScout
4
- VERSION = '1.1.0'
4
+ VERSION = '3.0.1'
5
5
  end
@@ -4,7 +4,6 @@ require 'active_support'
4
4
  require 'active_support/core_ext'
5
5
  require 'json'
6
6
  require 'faraday'
7
- require 'faraday_middleware'
8
7
 
9
8
  require 'help_scout/version'
10
9
 
@@ -52,7 +51,6 @@ module HelpScout
52
51
 
53
52
  def configure
54
53
  yield(configuration)
55
- api.access_token = HelpScout.configuration.access_token
56
54
  end
57
55
 
58
56
  def default_mailbox
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: help_scout-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TaxJar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,36 +28,16 @@ dependencies:
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: 2.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.10'
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.10.1
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '1.0'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 0.10.1
58
- - - "<"
38
+ - - '='
59
39
  - !ruby/object:Gem::Version
60
- version: '1.0'
40
+ version: 2.9.0
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: awesome_print
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +203,7 @@ files:
223
203
  - ".rspec"
224
204
  - ".rubocop.yml"
225
205
  - ".travis.yml"
206
+ - CHANGELOG.md
226
207
  - CODE_OF_CONDUCT.md
227
208
  - Gemfile
228
209
  - LICENSE.txt
@@ -257,7 +238,7 @@ licenses:
257
238
  metadata:
258
239
  source_code_uri: https://github.com/taxjar/help_scout-sdk
259
240
  bug_tracker_uri: https://github.com/taxjar/help_scout-sdk/issues
260
- post_install_message:
241
+ post_install_message:
261
242
  rdoc_options: []
262
243
  require_paths:
263
244
  - lib
@@ -265,15 +246,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
246
  requirements:
266
247
  - - ">="
267
248
  - !ruby/object:Gem::Version
268
- version: '2.3'
249
+ version: '3.0'
269
250
  required_rubygems_version: !ruby/object:Gem::Requirement
270
251
  requirements:
271
252
  - - ">="
272
253
  - !ruby/object:Gem::Version
273
254
  version: '0'
274
255
  requirements: []
275
- rubygems_version: 3.0.3
276
- signing_key:
256
+ rubygems_version: 3.1.2
257
+ signing_key:
277
258
  specification_version: 4
278
259
  summary: Ruby Help Scout SDK
279
260
  test_files: []