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: 187b3d6e3fdfb1db8a9a9402bbfefe81ed114850
4
- data.tar.gz: 4fe413daf9829aaafd834d6e1b6f36a97a78d664
3
+ metadata.gz: c67b2ccd83449bf610df65a9654726d8f34937aa
4
+ data.tar.gz: e3a070ed3e73a4c4938df9b29976201e3901d0ab
5
5
  SHA512:
6
- metadata.gz: 631b8a2ca96c31748eeeeefd40ffd2fb68ccbf11550b31b0485c7c6e934b9983bc12737199628f8f62e14bae916ba71c42d856a68fff27d6a5a4540d4d26fe36
7
- data.tar.gz: 5e455c86ca9f317c170d3bbf7c977136915c8d2ffb937290dc29baceaf2db96ea60ae55d17821eebec4696e54ae777dc2a1a6abf9433bb7d772734963165ad8c
6
+ metadata.gz: 4cfa44771737bb759ee954b6cd307b71e519df5e2f4caa8f793a7fbb40875b9c4423ff1cefc504043534ad9536caec3babafbd085c6ef23595c73f1dbae2ebbb
7
+ data.tar.gz: 9244b995840da35dfce94cde37379cc3f8ebf4f6e24d30423e6279bb8dc40a1c474fdbcfe65affdda30e7dcb5275185d3b791cd382790d63bbefb4cc941bb132
@@ -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, username_or_api_key, password='X', logger=nil)
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FreshdeskApiclient
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
@@ -2,7 +2,19 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe FreshdeskApiclient do
5
- it 'has a version number' do
6
- expect(FreshdeskApiclient::VERSION).not_to be nil
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
@@ -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
- subject { FreshdeskApiclient::REST::Client.new(:domain, :api_key) }
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
- subject { FreshdeskApiclient::REST::Client.new(:domain, :api_key, :password) }
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(:domain, :api_key, nil, Logger.new(STDOUT)) }
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.2
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-02 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client