helpshift 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: ed3c12f40fea3748aa09775a3542d6bc709f0eaa
4
- data.tar.gz: be48a95475001a14feb6afcdbe4608bb5d8034c5
3
+ metadata.gz: 335563c1c94f9b4a4ceae79192b0ae7c744654c3
4
+ data.tar.gz: 012516faf88909af0d1fd1eefa617fb1890d9c79
5
5
  SHA512:
6
- metadata.gz: c44d4ac270044fee6dca3649d792a951de6c52248846bca011f7d8511ace724b46c0bda7507c714ba83ea848d5e9229fe040f2d4dcbaffe8c4ab217e2e55b653
7
- data.tar.gz: b2d2058a19742c493228f8828a4266ddc03a3a185f63fc355df384187cd7f0066748142cea230155b5c1fd29f9d73c787af3e1c5dc90f5a9af237ba7b2a6417f
6
+ metadata.gz: b99913c69d1dea78608e499f8e0a9bd0919bb71d4696af0d55d609fb0bacdbaf9f33745f7009ff7abf92264d3054b72cca5d09c760e090d592810ca666ee1ef1
7
+ data.tar.gz: 01262ab01a2f0d3d20bf249a09363580f09a719882e18ddc15efae9fef46e1c34895186728656f7c217a4b664f224ee9c96027baffbc8eddd696559123dbc09a
data/README.md CHANGED
@@ -29,11 +29,23 @@ end
29
29
 
30
30
  ## Usage
31
31
 
32
- Get issues:
32
+ Get Issues:
33
33
 
34
34
  ```ruby
35
- response = Helpshift::Api.new.get('/issues')
36
- response['issues']
35
+ resp = Helpshift.get('/issues')
36
+ resp['issues']
37
+ ```
38
+
39
+ Update Custom Issue Fields
40
+
41
+ Configure issue fields in Helpshift admin - https://[customer_domain].helpshift.com/admin/.
42
+ Navigate to Settings > Custom Issue Fields.
43
+
44
+ Then you can update custom fields for any issue:
45
+
46
+ ```ruby
47
+ resp = Helpshift.put('/issues/4', custom_fields: { my_number_field: { type: 'number', value: 43 } }.to_json)
48
+ resp['updated-data']['custom_fields']) #=> {'my_number_field' => { 'type' => 'number', 'value' => 43 }}
37
49
  ```
38
50
 
39
51
  ## Development
@@ -1,3 +1,3 @@
1
1
  module Helpshift
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
data/lib/helpshift.rb CHANGED
@@ -1,13 +1,43 @@
1
1
  require 'helpshift/version'
2
- require 'helpshift/configuration'
3
- require 'helpshift/api'
2
+ require 'httparty'
4
3
 
5
4
  module Helpshift
5
+ include HTTParty
6
+
7
+ BASE_DOMAIN = 'https://api.helpshift.com/v1/'.freeze
8
+ CONFIGURATION = Struct.new(:customer_domain, :api_key)
9
+ ConfigurationError = Class.new(StandardError)
10
+
6
11
  def self.config
7
- @config ||= Configuration.new
12
+ @config ||= CONFIGURATION.new
8
13
  end
9
14
 
10
15
  def self.configure
11
16
  yield(config)
12
17
  end
18
+
19
+ def self.base_uri
20
+ @base_uri ||= if config.customer_domain
21
+ "#{BASE_DOMAIN}#{config.customer_domain}"
22
+ else
23
+ raise ConfigurationError, 'customer_domain is required'
24
+ end
25
+ end
26
+
27
+ def self.headers
28
+ @headers ||= if config.api_key
29
+ require 'base64'
30
+ { 'Accept' => 'application/json', 'Authorization' => "Basic #{::Base64.encode64(config.api_key).gsub("\n", '')}" }
31
+ else
32
+ raise ConfigurationError, 'api_key is required'
33
+ end
34
+ end
35
+
36
+ def self.get(path, query = {})
37
+ perform_request Net::HTTP::Get, path, base_uri: base_uri, query: query, headers: headers, format: :json
38
+ end
39
+
40
+ def self.put(path, body)
41
+ perform_request Net::HTTP::Put, path, base_uri: base_uri, headers: headers, body: body, format: :json
42
+ end
13
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpshift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksandr Avoyants
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -114,8 +114,6 @@ files:
114
114
  - bin/setup
115
115
  - helpshift.gemspec
116
116
  - lib/helpshift.rb
117
- - lib/helpshift/api.rb
118
- - lib/helpshift/configuration.rb
119
117
  - lib/helpshift/version.rb
120
118
  homepage: https://github.com/shhavel/helpshift
121
119
  licenses:
data/lib/helpshift/api.rb DELETED
@@ -1,20 +0,0 @@
1
- require 'httparty'
2
- require 'base64'
3
-
4
- module Helpshift
5
- class Api
6
- include ::HTTParty
7
- format :json
8
-
9
- def initialize
10
- config = ::Helpshift.config
11
- raise ::Helpshift::Configuration::Error.new('Not configured') unless config.customer_domain && config.api_key
12
- self.class.base_uri "#{config.base_domain}#{config.customer_domain}"
13
- @headers = { 'Authorization' => "Basic #{::Base64.encode64(config.api_key).gsub("\n", '')}" }
14
- end
15
-
16
- def get(url, query = {})
17
- self.class.get(url, query: query, headers: @headers)
18
- end
19
- end
20
- end
@@ -1,13 +0,0 @@
1
- module Helpshift
2
- class Configuration
3
- BASE_DOMAIN = 'https://api.helpshift.com/v1/'.freeze
4
- Error = Class.new(StandardError)
5
-
6
- attr_reader :base_domain
7
- attr_accessor :customer_domain, :api_key
8
-
9
- def initialize
10
- @base_domain = BASE_DOMAIN
11
- end
12
- end
13
- end