anego 0.0.1

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: 9200e9fc5c76b343692b9f14b4b3325ceead2cd7
4
+ data.tar.gz: 1e7337a09e890a6840a46af63e1c4be2efcd3ef0
5
+ SHA512:
6
+ metadata.gz: 47960bac3893f381e6e6651187a9e20d83c1f95d4242639fb1341bc469441f0d4d4e47984efba285c21d6c94500a73bf34b2003ff44aec12db9275e939d0420b
7
+ data.tar.gz: a70696bf24cc0cc02a41aa15cf6dda0b81d1443005faf001586a08b15e0e9c3f0195d566d45c8ac8382f221ad541243f44f779a5941fdb97c87b07c86ef35309
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in anego.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 fakestarbaby
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,36 @@
1
+ # Anego
2
+
3
+ Ruby wrapper for the [App Annie API](https://support.appannie.com/hc/en-us/articles/204208844-Welcome-Index-)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'anego'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install anego
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ # Initialization
25
+ client = Anego::Client.new
26
+
27
+ # Accounts API
28
+ client.accounts
29
+ #=> GET /accounts
30
+ ```
31
+
32
+ ## ENV
33
+
34
+ ```
35
+ APP_ANNIE_API_KEY - App Annie API Key
36
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/anego.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'anego/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "anego"
8
+ spec.version = Anego::VERSION
9
+ spec.authors = ["fakestarbaby"]
10
+ spec.email = ["fakestarbaby@gmail.com"]
11
+ spec.summary = %q{Ruby wrapper for the App Annie API}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/fakestarbaby/anego"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rest-client"
22
+ spec.add_dependency "hashie"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "anego"
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
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/lib/anego.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "hashie"
2
+ require "json"
3
+ require "rest-client"
4
+
5
+ require "anego/client"
6
+ require "anego/errors"
7
+ require "anego/response"
8
+ require "anego/version"
@@ -0,0 +1,46 @@
1
+ module Anego
2
+ class Client
3
+ API_ENDPOINT = "https://api.appannie.com/v1.2"
4
+
5
+ def initialize(api_key: nil)
6
+ @api_key = api_key
7
+ end
8
+
9
+ def accounts
10
+ request :get, "/accounts"
11
+ end
12
+
13
+ private
14
+
15
+ def request(method, path)
16
+ Anego::Response.new(execute(method, path))
17
+ end
18
+
19
+ def execute(method, path)
20
+ begin
21
+ RestClient::Request.execute(
22
+ method: method,
23
+ url: api_endpoint(path),
24
+ headers: default_headers,
25
+ )
26
+ rescue RestClient::ExceptionWithResponse => err
27
+ raise err
28
+ end
29
+ end
30
+
31
+ def api_endpoint(path)
32
+ "#{API_ENDPOINT}#{path}"
33
+ end
34
+
35
+ def default_headers
36
+ {
37
+ Accept: "application/json",
38
+ Authorization: "Bearer #{api_key}",
39
+ }
40
+ end
41
+
42
+ def api_key
43
+ @api_key || ENV["APP_ANNIE_API_KEY"]
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Anego
2
+ class ExceptionWithResponse < RestClient::ExceptionWithResponse; end
3
+ end
@@ -0,0 +1,21 @@
1
+ module Anego
2
+ class Response
3
+ def initialize(response)
4
+ @raw_body = Hashie::Mash.new JSON.parse(response.to_s)
5
+ @raw_headers = Hashie::Mash.new(response.headers)
6
+ @raw_status = response.code
7
+ end
8
+
9
+ def body
10
+ @raw_body
11
+ end
12
+
13
+ def headers
14
+ @raw_headers
15
+ end
16
+
17
+ def status
18
+ @raw_status
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Anego
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anego
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - fakestarbaby
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-19 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Ruby wrapper for the App Annie API
70
+ email:
71
+ - fakestarbaby@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - anego.gemspec
82
+ - bin/console
83
+ - bin/setup
84
+ - lib/anego.rb
85
+ - lib/anego/client.rb
86
+ - lib/anego/errors.rb
87
+ - lib/anego/response.rb
88
+ - lib/anego/version.rb
89
+ homepage: https://github.com/fakestarbaby/anego
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Ruby wrapper for the App Annie API
113
+ test_files: []