pesamoni_ruby 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,213 @@
1
+ =begin
2
+ #Pesaway Pesamoni API Documentation
3
+
4
+ #Automate mobile money payments, bank transfers and more..
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+ =end
9
+
10
+ require 'uri'
11
+
12
+ module Pesamoni
13
+ class Configuration
14
+ # Defines url scheme
15
+ attr_accessor :scheme
16
+
17
+ # Defines url host
18
+ attr_accessor :host
19
+
20
+ # Defines url base path
21
+ attr_accessor :base_path
22
+
23
+ # Defines API keys used with API Key authentications.
24
+ #
25
+ # @return [Hash] key: parameter name, value: parameter value (API key)
26
+ #
27
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
28
+ # config.api_key['api_key'] = 'xxx'
29
+ attr_accessor :api_key
30
+
31
+ # Defines API key prefixes used with API Key authentications.
32
+ #
33
+ # @return [Hash] key: parameter name, value: API key prefix
34
+ #
35
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
36
+ # config.api_key_prefix['api_key'] = 'Token'
37
+ attr_accessor :api_key_prefix
38
+
39
+ # Defines the username used with HTTP basic authentication.
40
+ #
41
+ # @return [String]
42
+ attr_accessor :username
43
+
44
+ # Defines the password used with HTTP basic authentication.
45
+ #
46
+ # @return [String]
47
+ attr_accessor :password
48
+
49
+ # Defines the access token (Bearer) used with OAuth2.
50
+ attr_accessor :access_token
51
+
52
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
53
+ # details will be logged with `logger.debug` (see the `logger` attribute).
54
+ # Default to false.
55
+ #
56
+ # @return [true, false]
57
+ attr_accessor :debugging
58
+
59
+ # Defines the logger used for debugging.
60
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
61
+ #
62
+ # @return [#debug]
63
+ attr_accessor :logger
64
+
65
+ # Defines the temporary folder to store downloaded files
66
+ # (for API endpoints that have file response).
67
+ # Default to use `Tempfile`.
68
+ #
69
+ # @return [String]
70
+ attr_accessor :temp_folder_path
71
+
72
+ # The time limit for HTTP request in seconds.
73
+ # Default to 0 (never times out).
74
+ attr_accessor :timeout
75
+
76
+ # Set this to false to skip client side validation in the operation.
77
+ # Default to true.
78
+ # @return [true, false]
79
+ attr_accessor :client_side_validation
80
+
81
+ ### TLS/SSL setting
82
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
83
+ # Default to true.
84
+ #
85
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
86
+ #
87
+ # @return [true, false]
88
+ attr_accessor :verify_ssl
89
+
90
+ ### TLS/SSL setting
91
+ # Set this to false to skip verifying SSL host name
92
+ # Default to true.
93
+ #
94
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
95
+ #
96
+ # @return [true, false]
97
+ attr_accessor :verify_ssl_host
98
+
99
+ ### TLS/SSL setting
100
+ # Set this to customize the certificate file to verify the peer.
101
+ #
102
+ # @return [String] the path to the certificate file
103
+ #
104
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
105
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
106
+ attr_accessor :ssl_ca_cert
107
+
108
+ ### TLS/SSL setting
109
+ # Client certificate file (for client certificate)
110
+ attr_accessor :cert_file
111
+
112
+ ### TLS/SSL setting
113
+ # Client private key file (for client certificate)
114
+ attr_accessor :key_file
115
+
116
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
117
+ # Default to nil.
118
+ #
119
+ # @see The params_encoding option of Ethon. Related source code:
120
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
121
+ attr_accessor :params_encoding
122
+
123
+ attr_accessor :inject_format
124
+
125
+ attr_accessor :force_ending_format
126
+
127
+ def initialize
128
+ @scheme = 'https'
129
+ @host = 'pesamoni.com'
130
+ @base_path = '/api/live/v1'
131
+ @api_key = {}
132
+ @api_key_prefix = {}
133
+ @timeout = 0
134
+ @client_side_validation = true
135
+ @verify_ssl = true
136
+ @verify_ssl_host = true
137
+ @params_encoding = nil
138
+ @cert_file = nil
139
+ @key_file = nil
140
+ @debugging = false
141
+ @inject_format = false
142
+ @force_ending_format = false
143
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
144
+
145
+ yield(self) if block_given?
146
+ end
147
+
148
+ # The default Configuration object.
149
+ def self.default
150
+ @@default ||= Configuration.new
151
+ end
152
+
153
+ def configure
154
+ yield(self) if block_given?
155
+ end
156
+
157
+ def scheme=(scheme)
158
+ # remove :// from scheme
159
+ @scheme = scheme.sub(/:\/\//, '')
160
+ end
161
+
162
+ def host=(host)
163
+ # remove http(s):// and anything after a slash
164
+ @host = host.sub(/https?:\/\//, '').split('/').first
165
+ end
166
+
167
+ def base_path=(base_path)
168
+ # Add leading and trailing slashes to base_path
169
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
170
+ @base_path = '' if @base_path == '/'
171
+ end
172
+
173
+ def base_url
174
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
175
+ URI.encode(url)
176
+ end
177
+
178
+ # Gets API key (with prefix if set).
179
+ # @param [String] param_name the parameter name of API key auth
180
+ def api_key_with_prefix(param_name)
181
+ if @api_key_prefix[param_name]
182
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
183
+ else
184
+ @api_key[param_name]
185
+ end
186
+ end
187
+
188
+ # Gets Basic Auth token string
189
+ def basic_auth_token
190
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
191
+ end
192
+
193
+ # Returns Auth Settings hash for api client.
194
+ def auth_settings
195
+ {
196
+ 'apipassword' =>
197
+ {
198
+ type: 'api_key',
199
+ in: 'query',
200
+ key: 'apipassword',
201
+ value: api_key_with_prefix('apipassword')
202
+ },
203
+ 'apiusername' =>
204
+ {
205
+ type: 'api_key',
206
+ in: 'query',
207
+ key: 'apiusername',
208
+ value: api_key_with_prefix('apiusername')
209
+ },
210
+ }
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #Pesaway Pesamoni API Documentation
3
+
4
+ #Automate mobile money payments, bank transfers and more..
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module Pesamoni
14
+ class InlineResponse200
15
+ attr_accessor :status
16
+
17
+ attr_accessor :token
18
+
19
+ attr_accessor :description
20
+
21
+ attr_accessor :mobile
22
+
23
+ attr_accessor :statuscode
24
+
25
+ attr_accessor :transaction_type
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'status' => :'status',
31
+ :'token' => :'token',
32
+ :'description' => :'description',
33
+ :'mobile' => :'mobile',
34
+ :'statuscode' => :'statuscode',
35
+ :'transaction_type' => :'transaction_type'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'status' => :'String',
43
+ :'token' => :'String',
44
+ :'description' => :'String',
45
+ :'mobile' => :'String',
46
+ :'statuscode' => :'String',
47
+ :'transaction_type' => :'String'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
58
+
59
+ if attributes.has_key?(:'status')
60
+ self.status = attributes[:'status']
61
+ end
62
+
63
+ if attributes.has_key?(:'token')
64
+ self.token = attributes[:'token']
65
+ end
66
+
67
+ if attributes.has_key?(:'description')
68
+ self.description = attributes[:'description']
69
+ end
70
+
71
+ if attributes.has_key?(:'mobile')
72
+ self.mobile = attributes[:'mobile']
73
+ end
74
+
75
+ if attributes.has_key?(:'statuscode')
76
+ self.statuscode = attributes[:'statuscode']
77
+ end
78
+
79
+ if attributes.has_key?(:'transaction_type')
80
+ self.transaction_type = attributes[:'transaction_type']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ status == o.status &&
103
+ token == o.token &&
104
+ description == o.description &&
105
+ mobile == o.mobile &&
106
+ statuscode == o.statuscode &&
107
+ transaction_type == o.transaction_type
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Fixnum] Hash code
118
+ def hash
119
+ [status, token, description, mobile, statuscode, transaction_type].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.swagger_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :BOOLEAN
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ temp_model = Pesamoni.const_get(type).new
180
+ temp_model.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ next if value.nil?
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,12 @@
1
+ =begin
2
+ #Pesaway Pesamoni API Documentation
3
+
4
+ #Automate mobile money payments, bank transfers and more..
5
+ OpenAPI spec version: 1.0.4
6
+
7
+
8
+ =end
9
+
10
+ module Pesamoni
11
+ VERSION = '1.0.4'
12
+ end
@@ -0,0 +1,39 @@
1
+ =begin
2
+ #Pesaway Pesamoni API Documentation
3
+
4
+ #Automate mobile money payments, bank transfers and more..
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+
9
+ =end
10
+
11
+ # Common files
12
+ require 'pesamoni_ruby/api_client'
13
+ require 'pesamoni_ruby/api_error'
14
+ require 'pesamoni_ruby/version'
15
+ require 'pesamoni_ruby/configuration'
16
+
17
+ # Models
18
+ require 'pesamoni_ruby/models/inline_response_200'
19
+
20
+ # APIs
21
+ require 'pesamoni_ruby/api/default_api'
22
+
23
+ module Pesamoni
24
+ class << self
25
+ # Customize default settings for the SDK using block.
26
+ # Pesamoni.configure do |config|
27
+ # config.username = "xxx"
28
+ # config.password = "xxx"
29
+ # end
30
+ # If no block given, return the default Configuration object.
31
+ def configure
32
+ if block_given?
33
+ yield(Configuration.default)
34
+ else
35
+ Configuration.default
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ #Pesaway Pesamoni API Documentation
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+ =end
9
+
10
+ $:.push File.expand_path("../lib", __FILE__)
11
+ require "pesamoni_ruby/version"
12
+
13
+ Gem::Specification.new do |s|
14
+ s.name = "pesamoni_ruby"
15
+ s.version = Pesamoni::VERSION
16
+ s.platform = Gem::Platform::RUBY
17
+ s.authors = ["Pesamoni Limited"]
18
+ s.email = [""]
19
+ s.homepage = "https://rubygems.org/gems/pesamoni_ruby"
20
+ s.summary = "Pesaway Pesamoni API Documentation Ruby Gem"
21
+ s.description = "This gem maps to the Pesamoni API"
22
+ s.license = "Apache 2.0"
23
+ s.required_ruby_version = ">= 1.9"
24
+
25
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
26
+ s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
27
+
28
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
29
+ s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
30
+ s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
31
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
32
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
33
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
34
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
35
+
36
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
37
+ s.test_files = `find spec/*`.split("\n")
38
+ s.executables = []
39
+ s.require_paths = ["lib"]
40
+ end
@@ -0,0 +1,58 @@
1
+ =begin
2
+ #Pesaway Pesamoni API Documentation
3
+
4
+ #Automate mobile money payments, bank transfers and more..
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+
9
+ =end
10
+
11
+ require 'spec_helper'
12
+ require 'json'
13
+
14
+ # Unit tests for Pesamoni::DefaultApi
15
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
16
+ # Please update as you see appropriate
17
+ describe 'DefaultApi' do
18
+ before do
19
+ # run before each test
20
+ @instance = Pesamoni::DefaultApi.new
21
+ end
22
+
23
+ after do
24
+ # run after each test
25
+ end
26
+
27
+ describe 'test an instance of DefaultApi' do
28
+ it 'should create an instance of DefaultApi' do
29
+ expect(@instance).to be_instance_of(Pesamoni::DefaultApi)
30
+ end
31
+ end
32
+
33
+ # unit tests for transactions_post
34
+ # Below are parameters and their respective expected responses. In order to try out the service, simply click Try it out.
35
+ # @param method Enter a request method. To check for request methods &lt;a href&#x3D;&#39;&#39;&gt;click here&lt;/a&gt;
36
+ # @param amount Enter the amount you would like to request for. &lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept&lt;/b&gt;&lt;/p&gt;
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [String] :mobile Enter the mobile number you would like to execute the above method in format 256.... or 254...&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime&lt;/b&gt;&lt;/p&gt;
39
+ # @option opts [String] :holdername Enter name of payer for Visa/MasterCard transactions&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;cardaccept&lt;/b&gt;&lt;/p&gt;
40
+ # @option opts [String] :cardnumber Enter the Visa/MasterCard cardnumber&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;cardaccept&lt;/b&gt;&lt;/p&gt;
41
+ # @option opts [String] :cvv Enter the Visa/MasterCard cvv&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;cardaccept&lt;/b&gt;&lt;/p&gt;
42
+ # @option opts [String] :exp Enter the Visa/MasterCard expiry date in the format MM/YYYY e.g 07/2030&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;cardaccept&lt;/b&gt;&lt;/p&gt;
43
+ # @option opts [String] :currency Enter the currency you intend to make the transaction for Visa/MasterCard based transactions&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;cardaccept&lt;/b&gt;&lt;/p&gt;
44
+ # @option opts [String] :account Enter the Pesamoni account you would like to use for this transaction&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request method &lt;b&gt;paybills&lt;/b&gt;&lt;/p&gt;
45
+ # @option opts [String] :reference Enter your user generated transaction reference&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept&lt;/b&gt;&lt;/p&gt;
46
+ # @option opts [String] :genericmsg Enter your user generated generic message for the requested transaction&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept&lt;/b&gt;&lt;/p&gt;
47
+ # @option opts [String] :token Enter your user generated token for the above mentioned method&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept&lt;/b&gt;&lt;/p&gt;
48
+ # @option opts [String] :bouquet Enter the bouquet or package you would like to pay for&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;paybills&lt;/b&gt;&lt;/p&gt;
49
+ # @option opts [String] :payoption Enter your prefered payment option&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;paybills&lt;/b&gt;&lt;/p&gt;
50
+ # @option opts [String] :meternumber Enter the meter number for the intended payment&lt;p style&#x3D;\&quot;color:red\&quot;&gt;This method applies for request methods &lt;b&gt;paybills&lt;/b&gt;&lt;/p&gt;
51
+ # @return [InlineResponse200]
52
+ describe 'transactions_post test' do
53
+ it 'should work' do
54
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
+ end
56
+ end
57
+
58
+ end