help_scout 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c0f81a717d1e98ee61c2cfbea80a333f18cab74
4
+ data.tar.gz: 290d049dec86ebe919ce0cf9affc5906267b8511
5
+ SHA512:
6
+ metadata.gz: 6818f2cfbed3119f952677ab3de5880006bd3886e13f204e566b39086a7d5bcb19383de73cbf613823ad85fd6f4f864fc0c65eb0e94f8c66db8ac5f2f65b4d5e
7
+ data.tar.gz: 329b28bb44cad44336c025c7db49370a1ef399b40cfab2d4ae386fd8786fc2ec40968c4a488ae262100adc9c3c53b14469a64795403fd6d238b8e6441071a981
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.7
5
+ before_install: gem install bundler -v 1.12.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in help_scout.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Mark Mulder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # HelpScout
2
+
3
+ [![Build Status](https://travis-ci.org/Springest/help_scout.svg?branch=master)](https://travis-ci.org/Springest/help_scout)
4
+
5
+ This is a gem extracted out from our codebase at Springest. That means that it's currently not as general as it can be, we mostly do stuff with conversations and customers. At the moment we also pass in complete hash objects to create these conversations, something we want to improve on, but take note.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'help_scout'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install help_scout
22
+
23
+ ## Usage
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/springest/help_scout.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "help_scout"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'help_scout/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "help_scout"
8
+ spec.version = HelpScout::VERSION
9
+ spec.authors = ["Dennis Paagman", "Miriam Tocino", "Mark Mulder"]
10
+ spec.email = ["dennispaagman@gmail.com", "miriam.tocino@gmail.com", "markmulder@gmail.com"]
11
+
12
+ spec.summary = "HelpScout is a an api client for Help Scout"
13
+ spec.homepage = "https://github.com/Springest/help_scout"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "httparty", "~> 0.13"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "webmock", "~> 2.0"
27
+ spec.add_development_dependency "byebug"
28
+ end
@@ -0,0 +1,137 @@
1
+ require "help_scout/version"
2
+ require "httparty"
3
+
4
+ class HelpScout
5
+ attr_accessor :last_response
6
+
7
+ def initialize(api_key)
8
+ @api_key = api_key
9
+ end
10
+
11
+ # Public: Create conversation
12
+ #
13
+ # data - hash with data
14
+ #
15
+ # More info: http://developer.helpscout.net/help-desk-api/conversations/create/
16
+ #
17
+ # Returns conversation ID
18
+ def create_conversation(data)
19
+ post("conversations", { body: data })
20
+
21
+ # Extract ID of created conversation from the Location header
22
+ conversation_uri = last_response.headers["location"]
23
+ conversation_uri.match(/(\d+)\.json$/)[1]
24
+ end
25
+
26
+ # Public: Get conversation
27
+ #
28
+ # id - conversation ID
29
+ #
30
+ # More info: http://developer.helpscout.net/help-desk-api/objects/conversation/
31
+ #
32
+ # Returns hash from HS with conversation data
33
+ def get_conversation(id)
34
+ get("conversations/#{id}")
35
+ end
36
+
37
+ # Public: Get conversations
38
+ #
39
+ # mailbox_id - ID of mailbox (find these with get_mailboxes)
40
+ # page - integer of page to fetch (default: 1)
41
+ # modified_since - Only return conversations that have been modified since
42
+ # this UTC datetime (default: nil)
43
+ #
44
+ # More info: http://developer.helpscout.net/help-desk-api/conversations/list/
45
+ #
46
+ # Returns hash from HS with conversation data
47
+ def get_conversations(mailbox_id, page = 1, modified_since = nil)
48
+ options ={
49
+ page: page,
50
+ modified_since: modified_since,
51
+ }
52
+ get("mailboxes/#{mailbox_id}/conversations", options)
53
+ end
54
+
55
+ # Public: Update conversation
56
+ #
57
+ # id - conversation id
58
+ # data - hash with data
59
+ #
60
+ # More info: http://developer.helpscout.net/help-desk-api/conversations/update/
61
+ def update_conversation(id, data)
62
+ put("conversations/#{id}", { body: data })
63
+ end
64
+
65
+ # Public: Search for conversations
66
+ #
67
+ # query - term to search for
68
+ #
69
+ # More info: http://developer.helpscout.net/help-desk-api/search/conversations/
70
+ def search_conversations(query)
71
+ search("search/conversations", query)
72
+ end
73
+
74
+ # Public: Get customer
75
+ #
76
+ # id - customer id
77
+ #
78
+ # More info: http://developer.helpscout.net/help-desk-api/customers/get/
79
+ def get_customer(id)
80
+ get("customers/#{id}")
81
+ end
82
+
83
+ def get_mailboxes
84
+ get("mailboxes")
85
+ end
86
+
87
+ protected
88
+
89
+ def post(path, options = {})
90
+ options[:body] = options[:body].to_json if options[:body]
91
+
92
+ request(:post, path, options)
93
+ end
94
+
95
+ def put(path, options = {})
96
+ options[:body] = options[:body].to_json if options[:body]
97
+
98
+ request(:put, path, options)
99
+ end
100
+
101
+ def get(path, options = {})
102
+ request(:get, path, options)
103
+ end
104
+
105
+ def search(path, query, page_id = 1, items = [])
106
+ options = { query: { page: page_id, query: "(#{query})" } }
107
+
108
+ result = get(path, options)
109
+ if !result.empty?
110
+ next_page_id = page_id + 1
111
+ result["items"] += items
112
+ if next_page_id > result["pages"]
113
+ return result["items"]
114
+ else
115
+ search(path, query, next_page_id, result["items"])
116
+ end
117
+ end
118
+ end
119
+
120
+ def request(method, path, options)
121
+ uri = URI("https://api.helpscout.net/v1/#{path}.json")
122
+
123
+ # The password can be anything, it's not used, see:
124
+ # http://developer.helpscout.net/help-desk-api/
125
+ options = {
126
+ basic_auth: {
127
+ username: @api_key, password: 'X'
128
+ },
129
+ headers: {
130
+ 'Content-Type' => 'application/json'
131
+ }
132
+ }.merge(options)
133
+
134
+ @last_response = HTTParty.send(method, uri, options)
135
+ @last_response.parsed_response
136
+ end
137
+ end
@@ -0,0 +1,3 @@
1
+ class HelpScout
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: help_scout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dennis Paagman
8
+ - Miriam Tocino
9
+ - Mark Mulder
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2016-09-22 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.13'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.13'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.12'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.12'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '10.0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '10.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: webmock
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '2.0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: byebug
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ description:
100
+ email:
101
+ - dennispaagman@gmail.com
102
+ - miriam.tocino@gmail.com
103
+ - markmulder@gmail.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - ".travis.yml"
111
+ - Gemfile
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - help_scout.gemspec
118
+ - lib/help_scout.rb
119
+ - lib/help_scout/version.rb
120
+ homepage: https://github.com/Springest/help_scout
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.5.1
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: HelpScout is a an api client for Help Scout
144
+ test_files: []