freshdesk_apiclient 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c1325f27dbe6b78e075ca30e6bd13eac3ce703c
4
+ data.tar.gz: 5083628601c39740f5541df1cb37bf63fba26ddc
5
+ SHA512:
6
+ metadata.gz: 3ef19caa813097a04bc01c2615e9dc1cc21d7810772a1184faee30ea3c2af5dcbe20c0e7458d9266e3c4df3a9bbe31b8e61e6ca52242869ecb0ae635b27f24fc
7
+ data.tar.gz: d11d2ca82bd1e7d2a856b0f3cca693b80429eda9bd8ff0ce285d2ab08c52ded326ef417555af03d703b1eb20079ad0309a416867cb0dbc9383225707c15450af
data/.codeclimate.yml ADDED
@@ -0,0 +1,21 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+ brakeman:
5
+ enabled: false
6
+ eslint:
7
+ enabled: false
8
+ csslint:
9
+ enabled: false
10
+ duplication:
11
+ enabled: true
12
+ config:
13
+ languages:
14
+ - ruby
15
+ ratings:
16
+ paths:
17
+ - lib/**
18
+ - "**.rb"
19
+ exclude_paths:
20
+ - spec/**/*
21
+ - "**/vendor/**/*"
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ /spec/examples.txt
2
+ coverage/
3
+ *.gem
4
+ .config
5
+ lib/bundler/man
6
+ *.bundle
7
+ *.so
8
+ *.o
9
+ *.a
10
+ mkmf.log
11
+
12
+
13
+ /.yardoc
14
+ /Gemfile.lock
15
+ /_yardoc/
16
+ /coverage/
17
+ /doc/
18
+ /pkg/
19
+ /spec/reports/
20
+
21
+
22
+ # rspec failure tracking
23
+ .rspec_status
24
+
25
+ # Ignore bundler config.
26
+ /.bundle
27
+ /vendor/bundle/
28
+ /vendor/ruby/
29
+
30
+ # Ignore all log files and tempfiles.
31
+ /log/*
32
+ !/log/.keep
33
+ /tmp
34
+
35
+ # various artifacts
36
+ .project
37
+ .secret
38
+ .idea/
39
+ /spec/tmp/*
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,253 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ AllCops:
5
+ DisplayCopNames: true
6
+ Exclude:
7
+ - "vendor/**/*"
8
+ - "bin/**/*"
9
+ UseCache: false
10
+
11
+ # Commonly used screens these days easily fit more than 80 characters.
12
+ Metrics/LineLength:
13
+ Max: 120
14
+
15
+ # No space makes the method definition shorter and differentiates
16
+ # from a regular assignment.
17
+ Style/SpaceAroundEqualsInParameterDefault:
18
+ EnforcedStyle: no_space
19
+
20
+ Style/SpaceInsideBlockBraces:
21
+ # The space here provides no real gain in readability while consuming
22
+ # horizontal space that could be used for a better parameter name.
23
+ # Also {| differentiates better from a hash than { | does.
24
+ SpaceBeforeBlockParameters: false
25
+
26
+ # No trailing space differentiates better from the block:
27
+ # foo} means hash, foo } means block.
28
+ Style/SpaceInsideHashLiteralBraces:
29
+ EnforcedStyle: no_space
30
+
31
+
32
+ Style/CollectionMethods:
33
+ Description: Preferred collection methods.
34
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
35
+ Enabled: true
36
+ PreferredMethods:
37
+ collect: map
38
+ collect!: map!
39
+ find: detect
40
+ find_all: select
41
+ reduce: inject
42
+ Style/DotPosition:
43
+ Description: Checks the position of the dot in multi-line method calls.
44
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
45
+ Enabled: true
46
+ EnforcedStyle: leading
47
+ SupportedStyles:
48
+ - leading
49
+ - trailing
50
+ Style/FileName:
51
+ Description: Use snake_case for source file names.
52
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
53
+ Enabled: false
54
+ Exclude: []
55
+ Style/GuardClause:
56
+ Description: Check for conditionals that can be replaced with guard clauses
57
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
58
+ Enabled: false
59
+ MinBodyLength: 1
60
+ Style/IfUnlessModifier:
61
+ Description: Favor modifier if/unless usage when you have a single-line body.
62
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
63
+ Enabled: false
64
+ MaxLineLength: 80
65
+ Style/OptionHash:
66
+ Description: Don't use option hashes when you can use keyword arguments.
67
+ Enabled: false
68
+ Style/PercentLiteralDelimiters:
69
+ Description: Use `%`-literal delimiters consistently
70
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
71
+ Enabled: false
72
+ PreferredDelimiters:
73
+ "%": "()"
74
+ "%i": "()"
75
+ "%q": "()"
76
+ "%Q": "()"
77
+ "%r": "{}"
78
+ "%s": "()"
79
+ "%w": "()"
80
+ "%W": "()"
81
+ "%x": "()"
82
+ Style/PredicateName:
83
+ Description: Check the names of predicate methods.
84
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
85
+ Enabled: true
86
+ NamePrefix:
87
+ - is_
88
+ - has_
89
+ - have_
90
+ NamePrefixBlacklist:
91
+ - is_
92
+ Exclude:
93
+ - spec/**/*
94
+ Style/RaiseArgs:
95
+ Description: Checks the arguments passed to raise/fail.
96
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
97
+ Enabled: false
98
+ EnforcedStyle: exploded
99
+ SupportedStyles:
100
+ - compact
101
+ - exploded
102
+ Style/SignalException:
103
+ Description: Checks for proper usage of fail and raise.
104
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
105
+ Enabled: false
106
+ EnforcedStyle: semantic
107
+ SupportedStyles:
108
+ - only_raise
109
+ - only_fail
110
+ - semantic
111
+ Style/SingleLineBlockParams:
112
+ Description: Enforces the names of some block params.
113
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
114
+ Enabled: false
115
+ Methods:
116
+ - reduce:
117
+ - a
118
+ - e
119
+ - inject:
120
+ - a
121
+ - e
122
+ Style/SingleLineMethods:
123
+ Description: Avoid single-line methods.
124
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
125
+ Enabled: false
126
+ AllowIfMethodIsEmpty: true
127
+ Style/StringLiterals:
128
+ Description: Checks if uses of quotes match the configured preference.
129
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
130
+ Enabled: true
131
+ EnforcedStyle: single_quotes
132
+ SupportedStyles:
133
+ - single_quotes
134
+ - double_quotes
135
+ Style/StringLiteralsInInterpolation:
136
+ Description: Checks if uses of quotes inside expressions in interpolated strings
137
+ match the configured preference.
138
+ Enabled: true
139
+ EnforcedStyle: single_quotes
140
+ SupportedStyles:
141
+ - single_quotes
142
+ - double_quotes
143
+ Metrics/AbcSize:
144
+ Description: A calculated magnitude based on number of assignments, branches, and
145
+ conditions.
146
+ Enabled: false
147
+ Max: 15
148
+ Metrics/BlockLength:
149
+ ExcludedMethods: ['describe', 'context', 'shared_examples']
150
+ Metrics/ClassLength:
151
+ Description: Avoid classes longer than 100 lines of code.
152
+ Enabled: false
153
+ CountComments: false
154
+ Max: 100
155
+ Metrics/ModuleLength:
156
+ CountComments: false
157
+ Max: 100
158
+ Description: Avoid modules longer than 100 lines of code.
159
+ Enabled: false
160
+ Metrics/CyclomaticComplexity:
161
+ Description: A complexity metric that is strongly correlated to the number of test
162
+ cases needed to validate a method.
163
+ Enabled: false
164
+ Max: 6
165
+ Metrics/MethodLength:
166
+ Description: Avoid methods longer than 10 lines of code.
167
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
168
+ Enabled: false
169
+ CountComments: false
170
+ Max: 10
171
+ Metrics/ParameterLists:
172
+ Description: Avoid parameter lists longer than three or four parameters.
173
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
174
+ Enabled: false
175
+ Max: 5
176
+ CountKeywordArgs: true
177
+ Metrics/PerceivedComplexity:
178
+ Description: A complexity metric geared towards measuring complexity for a human
179
+ reader.
180
+ Enabled: false
181
+ Max: 7
182
+ Lint/AssignmentInCondition:
183
+ Description: Don't use assignment in conditions.
184
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
185
+ Enabled: false
186
+ AllowSafeAssignment: true
187
+ Style/InlineComment:
188
+ Description: Avoid inline comments.
189
+ Enabled: false
190
+ Style/AccessorMethodName:
191
+ Description: Check the naming of accessor methods for get_/set_.
192
+ Enabled: false
193
+ Style/Alias:
194
+ Description: Use alias_method instead of alias.
195
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
196
+ Enabled: false
197
+ Style/Documentation:
198
+ Description: Document classes and non-namespace modules.
199
+ Enabled: false
200
+ Style/DoubleNegation:
201
+ Description: Checks for uses of double negation (!!).
202
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
203
+ Enabled: false
204
+ Style/EachWithObject:
205
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
206
+ Enabled: false
207
+ Style/EmptyLiteral:
208
+ Description: Prefer literals to Array.new/Hash.new/String.new.
209
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
210
+ Enabled: false
211
+ Style/ModuleFunction:
212
+ Description: Checks for usage of `extend self` in modules.
213
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
214
+ Enabled: false
215
+ Style/OneLineConditional:
216
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
217
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
218
+ Enabled: false
219
+ Style/PerlBackrefs:
220
+ Description: Avoid Perl-style regex back references.
221
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
222
+ Enabled: false
223
+ Style/Send:
224
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
225
+ may overlap with existing methods.
226
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
227
+ Enabled: false
228
+ Style/SpecialGlobalVars:
229
+ Description: Avoid Perl-style global variables.
230
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
231
+ Enabled: false
232
+ Style/VariableInterpolation:
233
+ Description: Don't interpolate global, instance and class variables directly in
234
+ strings.
235
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
236
+ Enabled: false
237
+ Style/WhenThen:
238
+ Description: Use when x then ... for one-line cases.
239
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
240
+ Enabled: false
241
+ Lint/EachWithObjectArgument:
242
+ Description: Check for immutable argument given to each_with_object.
243
+ Enabled: true
244
+ Lint/HandleExceptions:
245
+ Description: Don't suppress exception.
246
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
247
+ Enabled: false
248
+ Lint/LiteralInCondition:
249
+ Description: Checks of literals used in conditions.
250
+ Enabled: false
251
+ Lint/LiteralInInterpolation:
252
+ Description: Checks for literals used in interpolation.
253
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1,2 @@
1
+ freshdesk_apiclient
2
+
data/.ruby-version ADDED
@@ -0,0 +1,2 @@
1
+ ruby-2.3.1
2
+
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.3.1
6
+ before_install:
7
+ - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
8
+ - gem update --system
9
+ - gem install bundler
10
+ script:
11
+ - bundle exec rspec
12
+ notifications:
13
+ email: false
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at erich@financialapps.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ # Specify your gem's dependencies in freshdesk_apiclient.gemspec
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Erich Quintero
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Erich Quintero
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.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # FreshdeskApiclient
2
+
3
+ A ruby API client for freshdesk.com.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'freshdesk_apiclient'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install freshdesk_apiclient
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
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/qbantek/freshdesk_apiclient. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "freshdesk_apiclient"
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(__FILE__)
data/bin/setup ADDED
@@ -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,30 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'freshdesk_apiclient/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'freshdesk_apiclient'
9
+ spec.version = FreshdeskApiclient::VERSION
10
+ spec.authors = ['Erich Quintero']
11
+ spec.email = ['qbantek@gmail.com']
12
+
13
+ spec.summary = 'A ruby API client for freshdesk.com.'
14
+ spec.homepage = 'https://github.com/qbantek/freshdesk_apiclient'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
20
+ spec.test_files = Dir['spec/**/*.rb']
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.14', '>= 1.14.3'
26
+ spec.add_development_dependency 'gem-release', '~> 0.7', '>= 0.7.4'
27
+ spec.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.47', '>= 0.47.1'
30
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require 'freshdesk_apiclient/version'
3
+
4
+ require 'freshdesk_apiclient/utils/loggeable'
5
+ require 'freshdesk_apiclient/utils/camelizable'
6
+
7
+ require 'freshdesk_apiclient/rest/resources'
8
+ require 'freshdesk_apiclient/rest/tickets'
9
+ require 'freshdesk_apiclient/rest/client'
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ module FreshdeskApiclient
3
+ module REST
4
+ class Client
5
+ include FreshdeskApiclient::Utils::Loggeable
6
+ include FreshdeskApiclient::Utils::Camelizable
7
+
8
+ RESOURCES = %i(tickets).freeze
9
+
10
+ # @param [String] domain
11
+ # @param [String] username_or_api_key
12
+ # @param [String] password
13
+ # @param [Hash] options
14
+ def initialize(domain, username_or_api_key, password='X', options={})
15
+ @base_url = "https://#{domain}.freshdesk.com/api/v2/"
16
+ @credentials = {username: username_or_api_key, password: password}
17
+ @logger = options[:logger] if options.key?(:logger) && options[:logger].respond_to?(:info)
18
+ end
19
+
20
+ # obj.method_missing(symbol [, *args] ) -> result
21
+ def method_missing(symbol, *arguments, &block)
22
+ if RESOURCES.include? symbol
23
+ class_name = camelize(symbol.to_s)
24
+ variable = "@#{class_name.downcase}"
25
+ unless instance_variable_defined? variable
26
+ klass = Object.const_get('FreshdeskApiclient').const_get('REST').const_get class_name
27
+ instance_variable_set(variable, klass.new(@base_url, credentials: @credentials, logger: logger))
28
+ end
29
+ instance_variable_get(variable)
30
+ else
31
+ super
32
+ end
33
+ end
34
+
35
+ def respond_to_missing?(method_sym, include_private=false)
36
+ RESOURCES.include?(method_sym) ? true : super
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ require 'rest-client'
3
+ require 'forwardable'
4
+ require 'base64'
5
+
6
+ module FreshdeskApiclient
7
+ module REST
8
+ class Resources
9
+ def initialize(base_url, options={})
10
+ @url = "#{base_url}/#{options[:path] || end_point}"
11
+ @headers = headers options[:credentials]
12
+ RestClient.log = options[:logger]
13
+ end
14
+
15
+ def list
16
+ RestClient::Request.execute(method: :get,
17
+ url: @url,
18
+ headers: @headers.dup.reject! {|key| [:'Content-Type'].include?(key) })
19
+ end
20
+
21
+ def create(json_payload)
22
+ RestClient::Request.execute(method: :post,
23
+ url: @url,
24
+ headers: @headers,
25
+ payload: json_payload)
26
+ end
27
+
28
+ protected
29
+
30
+ def end_point
31
+ self.class.name.split('::').last.downcase
32
+ end
33
+
34
+ private
35
+
36
+ def headers(credentials)
37
+ {
38
+ Authorization: "Basic #{Base64.encode64("#{credentials[:username]}:#{credentials[:password]}")}",
39
+ 'Content-Type': 'application/json',
40
+ Accept: 'application/json'
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../../../lib/freshdesk_apiclient/rest/resources' unless defined?(FreshdeskApiclient::REST::Resources)
3
+
4
+ module FreshdeskApiclient
5
+ module REST
6
+ class Tickets < FreshdeskApiclient::REST::Resources; end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module FreshdeskApiclient
3
+ module Utils
4
+ module Camelizable
5
+ def camelize(term)
6
+ string = term.to_s
7
+ string = string.sub(/^[a-z\d]*/) { $&.capitalize }
8
+ string.gsub!(%r{(?:_|(/))([a-z\d]*)}) { $2.capitalize.to_s }
9
+ string
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module FreshdeskApiclient
3
+ module Utils
4
+ module Loggeable
5
+ def logger
6
+ @logger ||= standard_out_logger
7
+ end
8
+
9
+ def standard_out_logger
10
+ require 'logger'
11
+ Logger.new(STDOUT).tap {|log| log.level = Logger::INFO }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module FreshdeskApiclient
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ desc 'Bumps the version to the next patch level, tags and pushes the code to
3
+ origin repository and releases the gem. BOOM!'
4
+ task :release do
5
+ system 'gem bump --tag --release'
6
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe FreshdeskApiclient do
5
+ it 'has a version number' do
6
+ expect(FreshdeskApiclient::VERSION).not_to be nil
7
+ end
8
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ require 'logger' unless defined?(Logger)
3
+ unless defined?(FreshdeskApiclient::Utils::Camelizable)
4
+ require_relative '../../lib/freshdesk_apiclient/utils/camelizable'
5
+ end
6
+ require_relative '../../lib/freshdesk_apiclient/utils/loggeable' unless defined?(FreshdeskApiclient::Utils::Loggeable)
7
+ require_relative '../../lib/freshdesk_apiclient/rest/client' unless defined?(FreshdeskApiclient::REST::Client)
8
+ require_relative '../../lib/freshdesk_apiclient/rest/tickets' unless defined?(FreshdeskApiclient::REST::Tickets)
9
+ require_relative '../../lib/freshdesk_apiclient/rest/resources' unless defined?(FreshdeskApiclient::REST::Resources)
10
+
11
+ describe FreshdeskApiclient::REST::Client do
12
+ subject { FreshdeskApiclient::REST::Client.new(:domain, :api_key) }
13
+ describe '#new' do
14
+ it 'sets the base_url for the given domain' do
15
+ expect(subject.instance_variable_get(:@base_url)).to eql("https://#{:domain}.freshdesk.com/api/v2/")
16
+ end
17
+
18
+ context 'when password is provided' do
19
+ subject { FreshdeskApiclient::REST::Client.new(:domain, :api_key, :password) }
20
+ it 'sets the credentials for the given parameters' do
21
+ expect(subject.instance_variable_get(:@credentials)[:username]).to eq(:api_key)
22
+ expect(subject.instance_variable_get(:@credentials)[:password]).to eq(:password)
23
+ end
24
+ end
25
+
26
+ context 'when password is not provided' do
27
+ it 'sets the credentials for the given api_key and default password' do
28
+ expect(subject.instance_variable_get(:@credentials)[:username]).to eq(:api_key)
29
+ expect(subject.instance_variable_get(:@credentials)[:password]).to eq('X')
30
+ end
31
+ end
32
+
33
+ it 'sets the credentials for the given parameters' do
34
+ expect(subject.instance_variable_get(:@credentials)[:username]).to eq(:api_key)
35
+ expect(subject.instance_variable_get(:@credentials)[:password]).to eq('X')
36
+ end
37
+
38
+ context 'when a logger option is not provided' do
39
+ it('does not sets the logger') { expect(subject.instance_variable_get(:@logger)).to be_nil }
40
+ end
41
+
42
+ context 'when a logger option is provided' do
43
+ subject { FreshdeskApiclient::REST::Client.new(:domain, :api_key, nil, logger: Logger.new(STDOUT)) }
44
+ it('sets the logger') { expect(subject.instance_variable_get(:@logger)).to be_a(Logger) }
45
+ end
46
+ end
47
+
48
+ FreshdeskApiclient::REST::Client::RESOURCES.each do |method|
49
+ it("responds to ##{method}") { expect(subject).to respond_to(method) }
50
+
51
+ describe "##{method}" do
52
+ it do
53
+ klass = Object.const_get('FreshdeskApiclient').const_get('REST').const_get subject.camelize(method.to_s)
54
+ expect(subject.send(method)).to be_an_instance_of(klass)
55
+ end
56
+ end
57
+
58
+ it "memoizes the result of ##{method}" do
59
+ first = subject.send(method)
60
+ second = subject.send(method)
61
+ expect(first.object_id).to eq(second.object_id)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../../lib/freshdesk_apiclient/rest/resources' unless defined?(FreshdeskApiclient::REST::Resources)
3
+
4
+ RSpec.describe FreshdeskApiclient::REST::Resources do
5
+ subject { FreshdeskApiclient::REST::Resources.new(:url, credentials: {username: :u, password: :p}) }
6
+
7
+ RSpec.shared_examples 'a resource' do
8
+ let(:get_headers) { {Authorization: "Basic dTpw\n", Accept: 'application/json'} }
9
+ let(:post_headers) { get_headers.merge('Content-Type': 'application/json') }
10
+ let(:path) { subject.class.name.split('::').last.downcase }
11
+
12
+ describe '#new' do
13
+ context 'when path option is provided' do
14
+ subject { FreshdeskApiclient::REST::Resources.new(:url, credentials: {username: :u, password: :p}, path: :foo) }
15
+ it 'sets the url using given path' do
16
+ expect(subject.instance_variable_get(:@url)).to eql("#{:url}/#{:foo}")
17
+ end
18
+ end
19
+
20
+ context 'when path option is not provided' do
21
+ it 'sets the url for the given resource' do
22
+ expect(subject.instance_variable_get(:@url)).to eql("#{:url}/#{path}")
23
+ end
24
+ end
25
+
26
+ it 'sets the Authorization header for the given credentials' do
27
+ expect(subject.instance_variable_get(:@headers)[:Authorization]).to eql(get_headers[:Authorization])
28
+ end
29
+
30
+ it 'sets the Accept header to accept JSON' do
31
+ expect(subject.instance_variable_get(:@headers)[:Accept]).to eql(get_headers[:Accept])
32
+ end
33
+
34
+ it 'sets the Content-Type header to indicate JSON content' do
35
+ expect(subject.instance_variable_get(:@headers)[:'Content-Type']).to eql(post_headers[:'Content-Type'])
36
+ end
37
+
38
+ it('sets the logger on RestClient') do
39
+ rest_client = object_double('RestClient', :log= => nil).as_stubbed_const
40
+ logger = Logger.new(STDOUT)
41
+ FreshdeskApiclient::REST::Resources.new(:url,
42
+ credentials: {
43
+ username: :u,
44
+ password: :p
45
+ },
46
+ logger: logger)
47
+ expect(rest_client).to have_received(:log=).with(logger)
48
+ end
49
+ end
50
+
51
+ describe '#list' do
52
+ it('executes the request as a GET') do
53
+ request = object_double('RestClient::Request', execute: nil).as_stubbed_const
54
+ subject.list
55
+ expect(request).to have_received(:execute).with(method: :get, url: "#{:url}/#{path}", headers: get_headers)
56
+ end
57
+ end
58
+
59
+ describe '#create' do
60
+ it('executes the request as a POST') do
61
+ request = object_double('RestClient::Request', execute: nil).as_stubbed_const
62
+ subject.create :payload
63
+ expect(request).to have_received(:execute).with(method: :post,
64
+ url: "#{:url}/#{path}",
65
+ headers: post_headers,
66
+ payload: :payload)
67
+ end
68
+ end
69
+ end
70
+
71
+ it_behaves_like 'a resource'
72
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'resources_spec' unless defined?(FreshdeskApiclient::REST::Resources)
3
+ require_relative '../../lib/freshdesk_apiclient/rest/resources' unless defined?(FreshdeskApiclient::REST::Resources)
4
+ require_relative '../../lib/freshdesk_apiclient/rest/tickets' unless defined?(FreshdeskApiclient::REST::Tickets)
5
+
6
+ describe FreshdeskApiclient::REST::Tickets do
7
+ subject { FreshdeskApiclient::REST::Tickets.new(:url, credentials: {username: :u, password: :p}) }
8
+
9
+ it_behaves_like 'a resource'
10
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/setup'
3
+ Bundler.setup
4
+
5
+ require 'freshdesk_apiclient'
6
+
7
+ RSpec.configure do |config|
8
+ # Enable flags like --only-failures and --next-failure
9
+ config.example_status_persistence_file_path = '.rspec_status'
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freshdesk_apiclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erich Quintero
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.14'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.14.3
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.14'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.14.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: gem-release
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.7'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.7.4
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.7'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 0.7.4
73
+ - !ruby/object:Gem::Dependency
74
+ name: rake
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '12.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 12.0.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 12.0.0
93
+ - !ruby/object:Gem::Dependency
94
+ name: rspec
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '3.5'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 3.5.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.5'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 3.5.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: rubocop
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '0.47'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 0.47.1
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.47'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 0.47.1
133
+ description:
134
+ email:
135
+ - qbantek@gmail.com
136
+ executables: []
137
+ extensions: []
138
+ extra_rdoc_files: []
139
+ files:
140
+ - ".codeclimate.yml"
141
+ - ".gitignore"
142
+ - ".hound.yml"
143
+ - ".rspec"
144
+ - ".rubocop.yml"
145
+ - ".ruby-gemset"
146
+ - ".ruby-version"
147
+ - ".travis.yml"
148
+ - CODE_OF_CONDUCT.md
149
+ - Gemfile
150
+ - LICENSE
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - freshdesk_apiclient.gemspec
157
+ - lib/freshdesk_apiclient.rb
158
+ - lib/freshdesk_apiclient/rest/client.rb
159
+ - lib/freshdesk_apiclient/rest/resources.rb
160
+ - lib/freshdesk_apiclient/rest/tickets.rb
161
+ - lib/freshdesk_apiclient/utils/camelizable.rb
162
+ - lib/freshdesk_apiclient/utils/loggeable.rb
163
+ - lib/freshdesk_apiclient/version.rb
164
+ - lib/tasks/releaser.rake
165
+ - spec/freshdesk_apiclient_spec.rb
166
+ - spec/rest/client_spec.rb
167
+ - spec/rest/resources_spec.rb
168
+ - spec/rest/tickets_spec.rb
169
+ - spec/spec_helper.rb
170
+ homepage: https://github.com/qbantek/freshdesk_apiclient
171
+ licenses:
172
+ - MIT
173
+ metadata: {}
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ requirements: []
189
+ rubyforge_project:
190
+ rubygems_version: 2.6.10
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: A ruby API client for freshdesk.com.
194
+ test_files:
195
+ - spec/rest/client_spec.rb
196
+ - spec/rest/tickets_spec.rb
197
+ - spec/rest/resources_spec.rb
198
+ - spec/freshdesk_apiclient_spec.rb
199
+ - spec/spec_helper.rb