help_scout-sdk 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d4c58f9f96b57b2d1bbc0cd69ad741ffa6201244861167992e8212901d491d2
4
- data.tar.gz: 055c66adf697283a7836ce6fdb91156cea27ea1cddf0fc6f8b2c05c07ed174a8
3
+ metadata.gz: 7d88954135888a77486265cfd3a3755711a419b1883c0e4af31e3c3671d0e67f
4
+ data.tar.gz: beeb0ecb380ab39348823a61f1d6533617f093e9142c3f78dc0bcb1efff20064
5
5
  SHA512:
6
- metadata.gz: 2058da0b726acce0ef9993b40e827bb2be27f2947c78dfcb57216e51acb3fbcd4969b86a658e621e1bd63c1e6410f291a55cb2aaa03fd446374208e2376eeed0
7
- data.tar.gz: 10b8bbca725910b62a0b3120247506d50b8c7e3f34ed50a39ae2ddeb340d9081803b66d2649e9a9b410de4d1af2eb346372f3b96bcb6e7543f38e6f7c790f163
6
+ metadata.gz: dd1bd18e9d42821f7df2f1e397fd322af8d765ce522cddffd90b93d24d7390fec98f8a9d381bcf92e64896797c9726d62f8ea687bc6e4044c15592592c1b0b68
7
+ data.tar.gz: 278dd433006623d04f155b6b30521b6645eb13659c811282efe30cb5d00c4c755877158640a6411cac50dfd968770491b94c78d1588f511ab7cc4402532efd96
@@ -0,0 +1,29 @@
1
+ ### master (unreleased)
2
+
3
+ ### 2.0.0 / 2019-07-19
4
+
5
+ Breaking Changes:
6
+
7
+ * Removes HelpScout::Configuration#access_token and writer to avoid multiple sources
8
+ of truth for access token values ([#14](https://github.com/taxjar/help_scout-sdk/pull/14))
9
+
10
+ Enhancements:
11
+
12
+ * Adds support for `HelpScout::Thread.create`, `HelpScout::Thread.get`, and
13
+ `HelpScout::Thread#update` (Justin White, [#13](https://github.com/taxjar/help_scout-sdk/pull/13))
14
+
15
+ ### 1.1.0 / 2019-06-20
16
+
17
+ ### 1.0.2 / 2019-06-07
18
+
19
+ ### 1.0.1 / 2019-06-07
20
+
21
+ ### 1.0.0 / 2019-06-05
22
+
23
+ Breaking Changes:
24
+
25
+ * Drops support for the Mailbox 1.0 API ([#2](https://github.com/taxjar/help_scout-sdk/pull/2))
26
+
27
+ Enhancements:
28
+
29
+ * 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/)
@@ -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
@@ -52,7 +52,6 @@ module HelpScout
52
52
 
53
53
  def configure
54
54
  yield(configuration)
55
- api.access_token = HelpScout.configuration.access_token
56
55
  end
57
56
 
58
57
  def default_mailbox
@@ -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
@@ -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 = '2.0.0'
5
5
  end
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: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TaxJar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -223,6 +223,7 @@ files:
223
223
  - ".rspec"
224
224
  - ".rubocop.yml"
225
225
  - ".travis.yml"
226
+ - CHANGELOG.md
226
227
  - CODE_OF_CONDUCT.md
227
228
  - Gemfile
228
229
  - LICENSE.txt