api_six_client 1.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
+ SHA256:
3
+ metadata.gz: 91c206ff7f1609af9629912eee16193d35d30e338b36219f19f2ed692767b270
4
+ data.tar.gz: ba64baadd31593c26d7dcc254618eb1ea1c805fb1ee37716167a3daf09610e05
5
+ SHA512:
6
+ metadata.gz: 680c9182a05be3a2dc6659f19fb2d4bb5f262890c4204c9343aa1495c86c5b4087bf0c2bdc2dc75c4c2a79fda4ebc7c515025d6745ae76ce6ed81530632c6c56
7
+ data.tar.gz: ab471b68c23c0549ecf449fa5f0e45529bcd72d08c059df30cae86e10ae963339ffcd9f8b172aeedb277e96e82105b616a4b9043c6a224d38e8219ae3b2d6c0f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in api_six_client.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ api_six_client (1.0.1)
5
+ faraday (~> 1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (1.10.3)
11
+ faraday-em_http (~> 1.0)
12
+ faraday-em_synchrony (~> 1.0)
13
+ faraday-excon (~> 1.1)
14
+ faraday-httpclient (~> 1.0)
15
+ faraday-multipart (~> 1.0)
16
+ faraday-net_http (~> 1.0)
17
+ faraday-net_http_persistent (~> 1.0)
18
+ faraday-patron (~> 1.0)
19
+ faraday-rack (~> 1.0)
20
+ faraday-retry (~> 1.0)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-em_http (1.0.0)
23
+ faraday-em_synchrony (1.0.0)
24
+ faraday-excon (1.1.0)
25
+ faraday-httpclient (1.0.1)
26
+ faraday-multipart (1.0.4)
27
+ multipart-post (~> 2)
28
+ faraday-net_http (1.0.1)
29
+ faraday-net_http_persistent (1.2.0)
30
+ faraday-patron (1.0.0)
31
+ faraday-rack (1.0.0)
32
+ faraday-retry (1.0.3)
33
+ multipart-post (2.3.0)
34
+ rake (13.0.6)
35
+ ruby2_keywords (0.0.5)
36
+
37
+ PLATFORMS
38
+ arm64-darwin-21
39
+ x86_64-linux
40
+
41
+ DEPENDENCIES
42
+ api_six_client!
43
+ rake (~> 13.0)
44
+
45
+ BUNDLED WITH
46
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Eugene Dobrorodnov
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,37 @@
1
+ # ApiSixClient
2
+
3
+ ApiSix is a Ruby gem that provides access to various Lytics services.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'api_six_client', git: 'git@github.com:lytics-as/api-six-client.git'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ brg_client = ApiSixClient::Brg.new(endpoint: 'https://...', auth_token: 'secret')
21
+ brg_client.get('/business_units')
22
+ ```
23
+
24
+ or if you use Rails
25
+
26
+ ```ruby
27
+ # config/initializers/api_six_client.rb
28
+
29
+ ApiSixClient.configure do |config|
30
+ config.endpoint = 'https://...'
31
+ config.auth_token = 'secret'
32
+ end
33
+
34
+ brg_client = ApiSixClient::Brg.new
35
+ brg_client.get('/business_units')
36
+
37
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/api_six_client/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "api_six_client"
7
+ spec.version = ApiSixClient::VERSION
8
+ spec.authors = ["Eugene Dobrorodnov"]
9
+ spec.email = ["ei.dobrorodnov@gmail.com"]
10
+
11
+ spec.summary = "Lytics ApiSix client"
12
+ spec.description = "ApiSix is a Ruby gem that provides access to various Lytics services."
13
+ spec.homepage = "https://github.com/lytics-as/api-six-client"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.metadata["changelog_uri"] = "#{spec.homepage }/releases"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'faraday', '~> 1'
33
+
34
+ # For more information and examples about making a new gem, checkout our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "api_six_client"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ 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,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'json'
5
+
6
+ module ApiSixClient
7
+ class Base
8
+ attr_reader :endpoint
9
+
10
+ def initialize(endpoint: nil, auth_token: nil)
11
+ @endpoint = endpoint || ApiSixClient.config.endpoint
12
+ @auth_token = auth_token || ApiSixClient.config.auth_token
13
+
14
+ raise Errors::EndpointIsEmpty unless @endpoint
15
+ raise Errors::AuthTokenIsEmpty unless @auth_token
16
+ end
17
+
18
+ def post(path, params = {}, headers = {})
19
+ request __method__, path, params, headers
20
+ end
21
+
22
+ def get(path, params = {}, headers = {})
23
+ request __method__, path, params, headers
24
+ end
25
+
26
+ def patch(path, params = {}, headers = {})
27
+ request __method__, path, params, headers
28
+ end
29
+
30
+ def put(path, params = {}, headers = {})
31
+ request __method__, path, params, headers
32
+ end
33
+
34
+ private
35
+
36
+ def service_path
37
+ self.class.name.split('::').last.downcase
38
+ end
39
+
40
+ def request(method, path, params = {}, headers = {})
41
+ response = connection.run_request(method, "#{endpoint}/#{service_path}/#{path}", params.to_json, headers)
42
+ res = JSON.parse(response.body)
43
+
44
+ return res.with_indifferent_access if res.is_a?(Hash)
45
+ return res.map(&:with_indifferent_access) if res.is_a?(Array)
46
+
47
+ res
48
+ end
49
+
50
+ def connection
51
+ @connection ||=
52
+ Faraday.new(url: endpoint) do |faraday|
53
+ faraday.use Faraday::Response::RaiseError
54
+
55
+ faraday.headers['Content-Type'] = 'application/json'
56
+ faraday.headers['apikey'] = @auth_token
57
+
58
+ faraday.request :url_encoded
59
+ faraday.adapter :net_http
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApiSixClient
4
+ class Config
5
+ attr_accessor :endpoint, :auth_token
6
+
7
+ def initialize(endpoint: nil, auth_token: nil)
8
+ @endpoint = endpoint
9
+ @auth_token = auth_token
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApiSixClient
4
+ module Errors
5
+ class EndpointIsEmpty < StandardError; end
6
+ class AuthTokenIsEmpty < StandardError; end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApiSixClient
4
+ VERSION = "1.0.1"
5
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'api_six_client/version'
4
+ require 'api_six_client/config'
5
+ require 'api_six_client/base'
6
+ require 'api_six_client/errors'
7
+
8
+ module ApiSixClient
9
+ def self.config
10
+ @config ||= Config.new
11
+ end
12
+
13
+ def self.configure
14
+ yield(config)
15
+ end
16
+
17
+ class Brg < Base; end
18
+ class Gbk < Base; end
19
+ class Kms < Base; end
20
+ class Lyr < Base; end
21
+ class Mat < Base; end
22
+ class Val < Base; end
23
+ class Prj < Base; end
24
+ class Fin < Base; end
25
+ class Olc < Base; end
26
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: api_six_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eugene Dobrorodnov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ description: ApiSix is a Ruby gem that provides access to various Lytics services.
28
+ email:
29
+ - ei.dobrorodnov@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - api_six_client.gemspec
41
+ - bin/console
42
+ - bin/setup
43
+ - lib/api_six_client.rb
44
+ - lib/api_six_client/base.rb
45
+ - lib/api_six_client/config.rb
46
+ - lib/api_six_client/errors.rb
47
+ - lib/api_six_client/version.rb
48
+ homepage: https://github.com/lytics-as/api-six-client
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ allowed_push_host: https://rubygems.org
53
+ homepage_uri: https://github.com/lytics-as/api-six-client
54
+ source_code_uri: https://github.com/lytics-as/api-six-client
55
+ changelog_uri: https://github.com/lytics-as/api-six-client/releases
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.4.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.3.26
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Lytics ApiSix client
75
+ test_files: []