app_token_api 1.0.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
+ SHA256:
3
+ metadata.gz: c6c9c4c8b41114311b3e83839e637371ccfc384b85df059c4320f90ab87a4841
4
+ data.tar.gz: 2b925012ac1a9f44c07d1a99ca50f6ecda24e61f48b1562f9e581d0ca2622043
5
+ SHA512:
6
+ metadata.gz: e327a6337caa5e8142e37951756eb07247ba12c5b35a792f969f29f876c74f78f4e8d384d9789120f633321d2875b6bf3513025fd3f00ea02026b49b8268d534
7
+ data.tar.gz: dbcc66f390a18c1f12574bbf39a8b469ef13c1d910562c1bf4f05eaebb79598e6d20796ae553159397fa011fe8e6ca48e636249deba3b2e03389f9b8c3a70474
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake', '~> 12.3.3'
7
+ end
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Hydrogen Web Components
2
+
3
+ For more information, please visit [https://www.hydrogenplatform.com/no-code](https://www.hydrogenplatform.com/no-code)
4
+
5
+ ## Requirements
6
+ 1. Ruby 2.7+
7
+
8
+ ## Installation
9
+
10
+ ### Install the gem locally:
11
+
12
+ ```shell
13
+ gem build app_token_api.gemspec
14
+ gem install app_token_api-1.0.0.gem
15
+ ```
16
+ (for development, run `gem install --dev ./app_token_api-1.0.0.gem` to install the development dependencies)
17
+
18
+ Finally add this to the Gemfile:
19
+
20
+ gem 'app_token_api', '~> 1.0.0'
21
+
22
+ ### Include the Ruby code directly
23
+
24
+ Include the Ruby code directly using `-I` as follows:
25
+
26
+ ```shell
27
+ ruby -Ilib script.rb
28
+ ```
29
+
30
+ ## Getting Started
31
+
32
+ Please first follow the [installation](#installation) instructions. Then make sure you use the proper base URL:
33
+
34
+ ### Base URL
35
+ Follow steps to verify the base URL path:
36
+
37
+ 1. Go to configuration file located under lib folder.
38
+ 2. Search for @host and change/verify the URL according to the environment.
39
+
40
+ **Sandbox Base URL**
41
+ https://sandbox.hydrogenplatform.com/admin/v1
42
+
43
+ **Production Base URL**
44
+ https://api.hydrogenplatform.com/admin/v1
45
+
46
+ ### Sample Code
47
+ Now you are ready to execute the following Ruby code:
48
+
49
+ ```ruby
50
+ # Load the gem
51
+ require 'admin_api'
52
+
53
+ #### Get App Token
54
+
55
+ api_instance = AdminApi::AutoGenerateAppTokenApi.new
56
+
57
+ attribMap = [{"name" => "public-key", "value" => "xxxx"},{"name" => "client-id", "value" => "xxxx"}, {"name" => "card-id", "value" => "xxxx"}]
58
+
59
+ appTokenConfig = {}
60
+ appTokenConfig['appName'] = [{'app_name':'pfm_cash_flow', 'auth_type':'password_credentials'}]
61
+ appTokenConfig['userAccessToken'] = userAuthToken
62
+ appTokenConfig['attribMap'] = attribMap
63
+ appTokenConfig['isEmbed'] = TRUE
64
+ appTokenConfig['isCredsPassed'] = TRUE
65
+ appTokenConfig['clientId'] = "xxxx"
66
+ appTokenConfig['clientSecret'] = "xxxx"
67
+ appTokenConfig['username'] = "xxxx"
68
+ appTokenConfig['password'] = "xxxx"
69
+ appTokenConfig['basePath'] = "https://api.hydrogenplatform.com/admin/v1"
70
+
71
+
72
+ begin
73
+ #getAppToken
74
+ result = api_instance.get_app_token_using_get(appTokenConfig)
75
+ p result
76
+ rescue AdminApi::ApiError => e
77
+ puts "Exception when calling AppTokenApi->get_app_token_using_get: #{e}"
78
+ end
79
+
80
+ ```
81
+
82
+ ## Author
83
+ The Hydrogen Technology Corporation
84
+
85
+ https://www.hydrogenplatform.com
86
+
87
+ *Generated using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen)*
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
6
+ rescue LoadError
7
+ # no rspec available
8
+ end
@@ -0,0 +1,45 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ #Hydrogen Admin API
5
+
6
+ #The Hydrogen Admin API
7
+
8
+ OpenAPI spec version: 1.3.0
9
+ Contact: info@hydrogenplatform.com
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
11
+ Swagger Codegen version: 2.4.15
12
+
13
+ =end
14
+
15
+ $:.push File.expand_path("../lib", __FILE__)
16
+ require "admin_api/version"
17
+
18
+ Gem::Specification.new do |s|
19
+ s.name = "app_token_api"
20
+ s.version = AdminApi::VERSION
21
+ s.platform = Gem::Platform::RUBY
22
+ s.authors = ["hydrogen"]
23
+ s.email = ["info@hydrogenplatform.com"]
24
+ s.homepage = "https://github.com/swagger-api/swagger-codegen"
25
+ s.summary = "Hydrogen Admin API Ruby Gem"
26
+ s.description = "The Hydrogen Admin API"
27
+ s.license = "Unlicense"
28
+ s.required_ruby_version = ">= 1.9"
29
+
30
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
31
+ s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
32
+
33
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
34
+ s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
35
+ s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
36
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
37
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
38
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
39
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
40
+
41
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
42
+ s.test_files = `find spec/*`.split("\n")
43
+ s.executables = []
44
+ s.require_paths = ["lib"]
45
+ end
data/git_push.sh ADDED
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ #
3
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
4
+ #
5
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6
+ #
7
+ # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
8
+
9
+ git_user_id=$1
10
+ git_repo_id=$2
11
+ release_note=$3
12
+
13
+ if [ "$git_user_id" = "" ]; then
14
+ git_user_id=""
15
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16
+ fi
17
+
18
+ if [ "$git_repo_id" = "" ]; then
19
+ git_repo_id=""
20
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21
+ fi
22
+
23
+ if [ "$release_note" = "" ]; then
24
+ release_note=""
25
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26
+ fi
27
+
28
+ # Initialize the local directory as a Git repository
29
+ git init
30
+
31
+ # Adds the files in the local repository and stages them for commit.
32
+ git add .
33
+
34
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
35
+ git commit -m "$release_note"
36
+
37
+ # Sets the new remote
38
+ git_remote=`git remote`
39
+ if [ "$git_remote" = "" ]; then # git remote not defined
40
+
41
+ if [ "$GIT_TOKEN" = "" ]; then
42
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44
+ else
45
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46
+ fi
47
+
48
+ fi
49
+
50
+ git pull origin master
51
+
52
+ # Pushes (Forces) the changes in the local repository up to the remote repository
53
+ echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54
+ git push origin master 2>&1 | grep -v 'To https'
55
+
data/lib/admin_api.rb ADDED
@@ -0,0 +1,42 @@
1
+ =begin
2
+ #Hydrogen Admin API
3
+
4
+ #The Hydrogen Admin API
5
+
6
+ OpenAPI spec version: 1.3.0
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'admin_api/api_client'
15
+ require 'admin_api/api_error'
16
+ require 'admin_api/version'
17
+ require 'admin_api/configuration'
18
+ require 'admin_api/auth_configuration'
19
+ # Models
20
+ require 'admin_api/models/app_token'
21
+
22
+ # APIs
23
+ require 'admin_api/api/app_token_api'
24
+ require 'admin_api/api/auto_generate_app_token_api'
25
+
26
+ module AdminApi
27
+ class << self
28
+ # Customize default settings for the SDK using block.
29
+ # AdminApi.configure do |config|
30
+ # config.username = "xxx"
31
+ # config.password = "xxx"
32
+ # end
33
+ # If no block given, return the default Configuration object.
34
+ def configure
35
+ if block_given?
36
+ yield(AuthConfiguration.default)
37
+ else
38
+ AuthConfiguration.default
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,74 @@
1
+ =begin
2
+ #Hydrogen Admin API
3
+
4
+ #The Hydrogen Admin API
5
+
6
+ OpenAPI spec version: 1.3.0
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15
10
+
11
+ =end
12
+
13
+ require 'uri'
14
+
15
+ module AdminApi
16
+ class AppTokenApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # getAppToken
23
+ # @param app_name app_name
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [Array<AppToken>]
26
+ def get_app_token_using_get(app_name, opts = {})
27
+ data, _status_code, _headers = get_app_token_using_get_with_http_info(app_name, opts)
28
+ data
29
+ end
30
+
31
+ # getAppToken
32
+ # @param app_name app_name
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(Array<AppToken>, Fixnum, Hash)>] Array<AppToken> data, response status code and response headers
35
+ def get_app_token_using_get_with_http_info(app_name, opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: AppTokenApi.get_app_token_using_get ...'
38
+ end
39
+ # verify the required parameter 'app_name' is set
40
+ if @api_client.config.client_side_validation && app_name.nil?
41
+ fail ArgumentError, "Missing the required parameter 'app_name' when calling AppTokenApi.get_app_token_using_get"
42
+ end
43
+ # resource path
44
+ local_var_path = '/app_token'
45
+
46
+ # query parameters
47
+ query_params = {}
48
+ query_params[:'app_name'] = @api_client.build_collection_param(app_name, :multi)
49
+
50
+ # header parameters
51
+ header_params = {}
52
+ # HTTP header 'Accept' (if needed)
53
+ header_params['Accept'] = @api_client.select_header_accept(['*/*'])
54
+
55
+ # form parameters
56
+ form_params = {}
57
+
58
+ # http body (model)
59
+ post_body = nil
60
+ auth_names = ['oauth2']
61
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
62
+ :header_params => header_params,
63
+ :query_params => query_params,
64
+ :form_params => form_params,
65
+ :body => post_body,
66
+ :auth_names => auth_names,
67
+ :return_type => 'Array<AppToken>')
68
+ if @api_client.config.debugging
69
+ @api_client.config.logger.debug "API called: AppTokenApi#get_app_token_using_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
70
+ end
71
+ return data, status_code, headers
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,130 @@
1
+ =begin
2
+ #Hydrogen Admin API
3
+
4
+ #The Hydrogen Admin API
5
+
6
+ OpenAPI spec version: 1.3.0
7
+ Contact: info@hydrogenplatform.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15
10
+
11
+ =end
12
+
13
+ require 'uri'
14
+
15
+ module AdminApi
16
+ class AutoGenerateAppTokenApi
17
+ attr_accessor :api_client
18
+ attr_accessor :auth_config
19
+
20
+ def initialize(api_client = ApiClient.default, auth_config = AuthConfiguration.default)
21
+ @api_client = api_client
22
+ @auth_config = auth_config
23
+ end
24
+ # getAppToken
25
+ # @param app_name app_name
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [Array<AppToken>]
28
+ def get_app_token_using_get(appTokenConfig = {})
29
+ data, _status_code, _headers = get_app_token_using_get_with_http_info(appTokenConfig)
30
+ data
31
+ end
32
+ def create_client_credential_return(appTokenConfig)
33
+ client_credentials_token = @auth_config.create_client_credential_return(appTokenConfig['clientId'], appTokenConfig['clientSecret'])
34
+ if @api_client.config.debugging
35
+ @api_client.config.logger.debug "API called: AppTokenApi#get_app_token_using_get\nData: #{client_credentials_token.inspect}"
36
+ end
37
+ return client_credentials_token
38
+ end
39
+
40
+ def create_password_credential_return(appTokenConfig)
41
+
42
+ password_credentials_token = @auth_config.create_password_credential_return(appTokenConfig['clientId'], appTokenConfig['clientSecret'],appTokenConfig['username'], appTokenConfig['password'] )
43
+ if @api_client.config.debugging
44
+ @api_client.config.logger.debug "API called: AppTokenApi#password_credentials_token\nData: #{client_credentials_token.inspect}"
45
+ end
46
+ return password_credentials_token
47
+ end
48
+ # getAppToken
49
+ # @param app_name app_name
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [Array<(Array<AppToken>, Fixnum, Hash)>] Array<AppToken> data, response status code and response headers
52
+ def get_app_token_using_get_with_http_info(appTokenConfig = {})
53
+ if @api_client.config.debugging
54
+ @api_client.config.logger.debug 'Calling API: AppTokenApi.get_app_token_using_get ...'
55
+ end
56
+ # verify the required parameter 'app_name' is set
57
+ if @api_client.config.client_side_validation && appTokenConfig['appName'] == nil?
58
+ fail ArgumentError, "Missing the required parameter 'app_name' when calling AppTokenApi.get_app_token_using_get"
59
+ end
60
+
61
+ template = "<tag app-token='##app_token##' ##attrib_map##></tag>";
62
+ @auth_config.config.host = appTokenConfig['basePath']
63
+ @api_client.config.host = appTokenConfig['basePath']
64
+
65
+ # resource path
66
+ local_var_path = '/app_token'
67
+
68
+ # query parameters
69
+ query_params = {}
70
+ #query_params[:'app_name'] = @api_client.build_collection_param(appTokenConfig['appName'], :multi)
71
+
72
+ # header parameters
73
+ header_params = {}
74
+ # HTTP header 'Accept' (if needed)
75
+ header_params['Accept'] = @api_client.select_header_accept(['*/*'])
76
+
77
+ # form parameters
78
+ form_params = {}
79
+
80
+ # http body (model)
81
+ post_body = nil
82
+ auth_names = ['oauth2']
83
+
84
+ app_names = appTokenConfig['appName']
85
+ response = [];
86
+
87
+ finalAttribMap = []
88
+ if appTokenConfig['attribMap']
89
+ finalAttribMap = appTokenConfig['attribMap'].map { |it| "#{it['name']}='#{it['value']}'"}
90
+ end
91
+
92
+ app_names.each do |app|
93
+ if app[:auth_type].downcase == 'client_credentials'
94
+ client_credentials_token = create_client_credential_return(appTokenConfig)
95
+ @api_client.config.access_token = client_credentials_token
96
+ elsif app[:auth_type].downcase == 'password_credentials'
97
+ @api_client.config.access_token = appTokenConfig['userAccessToken']
98
+ if appTokenConfig['isCredsPassed']
99
+ password_credentials_token = create_password_credential_return(appTokenConfig)
100
+ @api_client.config.access_token = password_credentials_token
101
+ end
102
+ end
103
+
104
+ appTokenData, status_code, headers = @api_client.call_api(:GET, '/app_token?app_name=' + app[:app_name],
105
+ :header_params => header_params,
106
+ :query_params => [],
107
+ :form_params => form_params,
108
+ :body => post_body,
109
+ :auth_names => auth_names,
110
+ :return_type => 'Array<AppToken>')
111
+ if @api_client.config.debugging
112
+ @api_client.config.logger.debug "API called: AppTokenApi#get_app_token_using_get\nData: #{appTokenData.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
113
+ end
114
+
115
+ appTokenValue = appTokenData && appTokenData.length()>0 ? appTokenData.values_at(0).map(&:app_token)[0] : '';
116
+ tagValue = app[:app_name].downcase.gsub(/_/, '-');
117
+ fillTemplateValue = template.gsub(/tag/, tagValue)
118
+ .gsub(/##app_token##/, appTokenValue)
119
+ .gsub(/##attrib_map##/, finalAttribMap!=nil ? finalAttribMap.join(' ') : '');
120
+ item ={}
121
+ item[app[:app_name]] = appTokenValue;
122
+ if appTokenConfig['isEmbed']
123
+ item[app[:app_name]] = fillTemplateValue;
124
+ end
125
+ response.append(item);
126
+ end
127
+ return response
128
+ end
129
+ end
130
+ end