freshdesk_apiclient 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c67b2ccd83449bf610df65a9654726d8f34937aa
|
4
|
+
data.tar.gz: e3a070ed3e73a4c4938df9b29976201e3901d0ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cfa44771737bb759ee954b6cd307b71e519df5e2f4caa8f793a7fbb40875b9c4423ff1cefc504043534ad9536caec3babafbd085c6ef23595c73f1dbae2ebbb
|
7
|
+
data.tar.gz: 9244b995840da35dfce94cde37379cc3f8ebf4f6e24d30423e6279bb8dc40a1c474fdbcfe65affdda30e7dcb5275185d3b791cd382790d63bbefb4cc941bb132
|
data/lib/freshdesk_apiclient.rb
CHANGED
@@ -7,3 +7,29 @@ require 'freshdesk_apiclient/utils/camelizable'
|
|
7
7
|
require 'freshdesk_apiclient/rest/resources'
|
8
8
|
require 'freshdesk_apiclient/rest/tickets'
|
9
9
|
require 'freshdesk_apiclient/rest/client'
|
10
|
+
|
11
|
+
module FreshdeskApiclient
|
12
|
+
def self.domain
|
13
|
+
@domain
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.domain=(domain)
|
17
|
+
@domain = domain
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.username_or_api_key
|
21
|
+
@username_or_api_key
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.username_or_api_key=(username_or_api_key)
|
25
|
+
@username_or_api_key = username_or_api_key
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.password
|
29
|
+
@password ||= 'X'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.password=(password)
|
33
|
+
@password = password
|
34
|
+
end
|
35
|
+
end
|
@@ -11,7 +11,10 @@ module FreshdeskApiclient
|
|
11
11
|
# @param [String] username_or_api_key
|
12
12
|
# @param [String] password
|
13
13
|
# @param [Logger] logger
|
14
|
-
def initialize(domain
|
14
|
+
def initialize(domain: FreshdeskApiclient.domain,
|
15
|
+
username_or_api_key: FreshdeskApiclient.username_or_api_key,
|
16
|
+
password: FreshdeskApiclient.password,
|
17
|
+
logger: nil)
|
15
18
|
@base_url = "https://#{domain}.freshdesk.com/api/v2/"
|
16
19
|
@credentials = {username: username_or_api_key, password: password}
|
17
20
|
@logger = logger
|
@@ -2,7 +2,19 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
RSpec.describe FreshdeskApiclient do
|
5
|
-
it
|
6
|
-
|
5
|
+
it('has a version number') { expect(FreshdeskApiclient::VERSION).not_to be nil }
|
6
|
+
|
7
|
+
before { FreshdeskApiclient.domain = :domain }
|
8
|
+
it('allows to set domain') { expect(FreshdeskApiclient.domain).to eq(:domain) }
|
9
|
+
|
10
|
+
before { FreshdeskApiclient.username_or_api_key = :u }
|
11
|
+
it('allows to set username_or_api_key') { expect(FreshdeskApiclient.username_or_api_key).to eq(:u) }
|
12
|
+
|
13
|
+
before { FreshdeskApiclient.password = :p }
|
14
|
+
it('allows to set password') { expect(FreshdeskApiclient.password).to eq(:p) }
|
15
|
+
|
16
|
+
context 'when password was not set' do
|
17
|
+
before { FreshdeskApiclient.password = nil }
|
18
|
+
it('has a default password') { expect(FreshdeskApiclient.password).to eq('X') }
|
7
19
|
end
|
8
20
|
end
|
data/spec/rest/client_spec.rb
CHANGED
@@ -9,14 +9,19 @@ require_relative '../../lib/freshdesk_apiclient/rest/tickets' unless defined?(Fr
|
|
9
9
|
require_relative '../../lib/freshdesk_apiclient/rest/resources' unless defined?(FreshdeskApiclient::REST::Resources)
|
10
10
|
|
11
11
|
describe FreshdeskApiclient::REST::Client do
|
12
|
-
|
12
|
+
before do
|
13
|
+
FreshdeskApiclient.domain = :domain
|
14
|
+
FreshdeskApiclient.username_or_api_key = :api_key
|
15
|
+
end
|
16
|
+
subject { FreshdeskApiclient::REST::Client.new }
|
13
17
|
describe '#new' do
|
14
18
|
it 'sets the base_url for the given domain' do
|
15
19
|
expect(subject.instance_variable_get(:@base_url)).to eql("https://#{:domain}.freshdesk.com/api/v2/")
|
16
20
|
end
|
17
21
|
|
18
22
|
context 'when password is provided' do
|
19
|
-
|
23
|
+
before { FreshdeskApiclient.password = :password }
|
24
|
+
subject { FreshdeskApiclient::REST::Client.new }
|
20
25
|
it 'sets the credentials for the given parameters' do
|
21
26
|
expect(subject.instance_variable_get(:@credentials)[:username]).to eq(:api_key)
|
22
27
|
expect(subject.instance_variable_get(:@credentials)[:password]).to eq(:password)
|
@@ -24,6 +29,7 @@ describe FreshdeskApiclient::REST::Client do
|
|
24
29
|
end
|
25
30
|
|
26
31
|
context 'when password is not provided' do
|
32
|
+
before { FreshdeskApiclient.password = nil }
|
27
33
|
it 'sets the credentials for the given api_key and default password' do
|
28
34
|
expect(subject.instance_variable_get(:@credentials)[:username]).to eq(:api_key)
|
29
35
|
expect(subject.instance_variable_get(:@credentials)[:password]).to eq('X')
|
@@ -35,7 +41,7 @@ describe FreshdeskApiclient::REST::Client do
|
|
35
41
|
end
|
36
42
|
|
37
43
|
context 'when a logger option is provided' do
|
38
|
-
subject { FreshdeskApiclient::REST::Client.new(:
|
44
|
+
subject { FreshdeskApiclient::REST::Client.new(logger: Logger.new(STDOUT)) }
|
39
45
|
it('sets the logger') { expect(subject.instance_variable_get(:@logger)).to be_a(Logger) }
|
40
46
|
end
|
41
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freshdesk_apiclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|