chatmeter 1.1.8

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
+ SHA256:
3
+ metadata.gz: 9d64e8edc503a5cdd9b9256468e41457be841a6e61db78dde68c7b781c5e9432
4
+ data.tar.gz: 6db45a0fea8f7f2cc138a3556c2e0bcc74e495b6cabdaf7343c8d625d9252940
5
+ SHA512:
6
+ metadata.gz: 357cfee8a87a64507990677d240339351d40ae3b0079d8020171034e3e68e2e77e598285cf7fdb94b97a7488bc04be93bd7243498bb4a7d47600814483654232
7
+ data.tar.gz: f2fbb3b6e4dc06e490410f935eb16bed8cfc5978537e976a992c7f190608caf44e56c40b4a6b49b8ee7e10fe263d4c395b751363d434d7fe965de6507508a8e8
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.4
5
+ before_install: gem install bundler -v 1.15.1
@@ -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 levi.brown@getg5.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,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in chatmeter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Levi Brown
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,40 @@
1
+ # Chatmeter
2
+
3
+ A ruby api wrapper for chatmeters REST API http://newapi.chatmeter.com/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'chatmeter'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install chatmeter
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ require 'chatmeter'
25
+ chatmeter = Chatmeter::API.new(:username => USERNAME, :password => PASSWORD)
26
+ ```
27
+
28
+ ## Development
29
+
30
+ 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.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/G5/chatmeter. 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.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "chatmeter"
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
data/chatmeter.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "chatmeter/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chatmeter"
8
+ spec.version = Chatmeter::VERSION
9
+ spec.authors = ["Levi Brown", "Kyle Rose", "Pablo Rodriguez"]
10
+ spec.email = ["levi.brown@getg5.com"]
11
+
12
+ spec.summary = %q{A ruby wrapper for the chatmeter API.}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/G5/chatmeter"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.15"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "pry"
37
+
38
+ spec.add_dependency "multi_json"
39
+ spec.add_dependency "excon"
40
+ spec.add_dependency "json"
41
+ end
@@ -0,0 +1,46 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ # GET /accounts for user
5
+ def get_accounts_for_user(user_id)
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ path: "/accounts/forUser/#{user_id}"
10
+ )[:accountIds]
11
+ end
12
+
13
+ # GET /accounts
14
+ def accounts(query={})
15
+ request(
16
+ expects: 200,
17
+ method: :get,
18
+ path: '/accounts',
19
+ query: query
20
+ )[:accounts]
21
+ end
22
+
23
+ # POST /accounts
24
+ def add_new_account(params)
25
+ request(
26
+ expects: 200,
27
+ method: :post,
28
+ path: "/accounts",
29
+ body: params.to_json
30
+ )
31
+ end
32
+
33
+ # GET account's groups
34
+ def get_account_groups(account_id)
35
+ request(
36
+ expects: 200,
37
+ method: :get,
38
+ path: "/groups",
39
+ query: {
40
+ accountId: account_id
41
+ }
42
+ )[:groups]
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,60 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ # GET /reviewBuilder/campaign/get
5
+ def list_all_campaigns
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ path: "/reviewBuilder/campaign/get"
10
+ )
11
+ end
12
+
13
+ # POST /reviewBuilder/campaign/create
14
+ def create_new_campaign(params)
15
+ request(
16
+ expects: 201,
17
+ method: :post,
18
+ path: "/reviewBuilder/campaign/create",
19
+ body: params.to_json
20
+ )
21
+ end
22
+
23
+ # GET /reviewBuilder/campaign/get/{campaignId}
24
+ def get_campaign_by_id(campaign_id)
25
+ request(
26
+ expects: 200,
27
+ method: :get,
28
+ path: "/reviewBuilder/campaign/get/#{campaign_id}"
29
+ )
30
+ end
31
+
32
+ # PUT /reviewBuilder/campaign/{campaignId}
33
+ def update_campaign(campaign_id, params)
34
+ request(
35
+ expects: 200,
36
+ method: :put,
37
+ path: "/reviewBuilder/campaign/#{campaign_id}",
38
+ body: params.to_json
39
+ )
40
+ end
41
+
42
+ # GET /reviewBuilder/campaign
43
+ def search_campaign(params={})
44
+ request(
45
+ expects: 200,
46
+ method: :get,
47
+ path: "/reviewBuilder/campaign?#{params.to_query}"
48
+ )
49
+ end
50
+
51
+ # DELETE /reviewBuilder/campaign/delete/{campaignId}
52
+ def delete_campaign(campaign_id)
53
+ request(
54
+ expects: 200,
55
+ method: :delete,
56
+ path: "/reviewBuilder/campaign/delete/#{campaign_id}"
57
+ )
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,23 @@
1
+ module Chatmeter
2
+ class API
3
+ module Errors
4
+ class Error < StandardError; end
5
+
6
+ class ErrorWithResponse < Error
7
+ attr_reader :response
8
+
9
+ def initialize(message, response)
10
+ message = message << "\nbody: #{response.body.inspect}"
11
+ super message
12
+ @response = response
13
+ end
14
+ end
15
+
16
+ class NotFound < ErrorWithResponse; end
17
+ class BadRequest < ErrorWithResponse; end
18
+ class Unauthorized < ErrorWithResponse; end
19
+ class Forbidden < ErrorWithResponse; end
20
+ class InternalServerError < ErrorWithResponse; end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,62 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ # GET /groups
5
+ def list_all_groups
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ path: "/groups"
10
+ )[:groups]
11
+ end
12
+
13
+ # POST /groups
14
+ def create_new_group(params)
15
+ request(
16
+ expects: 200,
17
+ method: :post,
18
+ path: "/groups",
19
+ body: params.to_json
20
+ )
21
+ end
22
+
23
+ # PUT /groups/{group_id}
24
+ def update_group(group_id, params)
25
+ request(
26
+ expects: 200,
27
+ method: :put,
28
+ path: "/groups/#{group_id}",
29
+ body: params.to_json
30
+ )
31
+ end
32
+
33
+ # DELETE /groups/{group_id}
34
+ def delete_group(group_id)
35
+ request(
36
+ expects: 200,
37
+ method: :delete,
38
+ path: "/groups/#{group_id}"
39
+ )
40
+ end
41
+
42
+ # POST /groups/{group_id}/locations
43
+ def update_group_locations(group_id, params)
44
+ request(
45
+ expects: 200,
46
+ method: :post,
47
+ path: "/groups/#{group_id}/locations",
48
+ body: params.to_json
49
+ )
50
+ end
51
+
52
+ # DELETE /groups/{group_id}/locations
53
+ def delete_group_locations(group_id,locationsIds)
54
+ request(
55
+ expects: 200,
56
+ method: :delete,
57
+ path: "/groups/#{group_id}/locations?locationIds=#{locationsIds.join(',')}"
58
+ )
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,63 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ # GET /locations
5
+ def get_all_locations(query={})
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ path: '/locations',
10
+ query: query
11
+ )
12
+ end
13
+
14
+ # GET /locations/externalId/{resellerLocationId}
15
+ def get_locations_by_reseller_location_id(reseller_location_id)
16
+ request(
17
+ expects: 200,
18
+ method: :get,
19
+ path: "/locations/externalId/#{reseller_location_id}"
20
+ )
21
+ end
22
+
23
+ # POST /locations
24
+ def add_new_location(fields)
25
+ request(
26
+ expects: 200,
27
+ method: :post,
28
+ path: '/locations',
29
+ body: fields.to_json
30
+ )
31
+ end
32
+
33
+ # PUT /locations/{locationId}
34
+ def update_location(location_id, fields)
35
+ request(
36
+ expects: 200,
37
+ method: :put,
38
+ path: "/locations/#{location_id}",
39
+ body: fields.to_json
40
+ )
41
+ end
42
+
43
+ # DELETE /locations/{locationId}
44
+ def delete_location(location_id)
45
+ request(
46
+ expects: 200,
47
+ method: :delete,
48
+ path: "/locations/#{location_id}"
49
+ )
50
+ end
51
+
52
+ # PUT /locations/restore (array)
53
+ def restore_location(location_ids)
54
+ request(
55
+ expects: 200,
56
+ method: :put,
57
+ path: '/locations/restore',
58
+ body: location_ids.to_json
59
+ )
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,14 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ def post_login(username, password)
5
+ request(
6
+ expects: 200,
7
+ method: :post,
8
+ path: '/login',
9
+ body: { username: username, password: password }.to_json
10
+ )
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,47 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # stub GET /accounts
6
+ Excon.stub(expects: 200, method: :get, path: '/v5/accounts') do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ body: {
10
+ accounts: [
11
+ {
12
+ id: "23232",
13
+ accountName: "Reseller 1"
14
+ }
15
+ ],
16
+ hasMore: false
17
+ },
18
+ status: 200
19
+ }
20
+ end
21
+
22
+ # stub GET /accounts
23
+ Excon.stub(expects: 200, method: :get, path: %r{\/v5\/accounts\/forUser\/\w*$}) do |params|
24
+ request_params, mock_data = parse_stub_params(params)
25
+ {
26
+ body: {
27
+ accountIds: [ "232323" ]
28
+ },
29
+ status: 200
30
+ }
31
+ end
32
+
33
+ # stub POST /accounts
34
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/accounts}) do |params|
35
+ params = JSON.parse(params[:body])
36
+ {
37
+ body: {
38
+ id: "23232",
39
+ accountName: params["accountName"]
40
+ },
41
+ status: 200
42
+ }
43
+ end
44
+
45
+ end
46
+ end
47
+ end