paghiper 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d52f289b7853e883c04bf6a96910668e0ecab3189bc43d3689f17d734c3d618
4
+ data.tar.gz: a4c9118ffc5be577653c19f7b6830dd49c2c10f4c3bbb117e23f9186bb4e492d
5
+ SHA512:
6
+ metadata.gz: af9549a633aae1f136a6caf4492572ac3839ed56a69ecb6341be9872beb6eaffa0d3b9ef9693679a609ee07cb904aed0129743be5c0610acf3300d774f383ff3
7
+ data.tar.gz: 21cf3746cd8671101e0eab34619378f0f98870321e8048eb9982bf9cd93ef8c6830fca649326fa6e908696d68ba18c8bb90197cac311b921b7ce5d617b111bfc
@@ -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
@@ -0,0 +1,18 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=8a0697336093e0a0b8aed2d934527c361ac20724bcfec0e68b9fdef71db5c005
4
+ sudo: false
5
+ language: ruby
6
+ rvm:
7
+ - 2.2
8
+ - 2.3
9
+ - 2.4
10
+ before_install: gem install bundler -v 1.15.1
11
+ before_script:
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
15
+ script:
16
+ - bundle exec rspec
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -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 gberdugo@gmail.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 paghiper.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Coyô Software
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.
@@ -0,0 +1,69 @@
1
+ # PAGHIPER
2
+
3
+ Ruby gem for [PAGHIPER](https://dev.paghiper.com/) API generation of "boletos" (brazilian cash payment method).
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/paghiper.svg)](https://badge.fury.io/rb/paghiper)
6
+ [![Build Status](https://travis-ci.com/coyosoftware/paghiper.svg?branch=master)](https://travis-ci.com/coyosoftware/paghiper)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/33a90218586cd93bb200/maintainability)](https://codeclimate.com/github/coyosoftware/paghiper/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/33a90218586cd93bb200/test_coverage)](https://codeclimate.com/github/coyosoftware/paghiper/test_coverage)
9
+
10
+ **Currently, gem supports version v1.3 of PAGHIPER API**
11
+
12
+ ## Installation
13
+
14
+ Add the following line in your Gemfile:
15
+
16
+ ```ruby
17
+ gem 'paghiper'
18
+ ```
19
+
20
+ and execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it through:
25
+
26
+ $ gem install paghiper
27
+
28
+ ## Configuration
29
+
30
+ Generate Rails initialization file
31
+
32
+ $ rails g paghiper:install
33
+
34
+ Configure your client settings
35
+
36
+ ```ruby
37
+ Paghiper.configure do |config|
38
+ config.api_key = 'apk_99999999-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
39
+ config.http_debug = true
40
+ end
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Generating boletos
46
+
47
+ ```ruby
48
+ Paghiper::Transaction.create(transaction_data)
49
+ ```
50
+
51
+ Check [API documentations](https://dev.paghiper.com/reference#gerar-boleto) of PAGHIPER required data to generate boletos.
52
+
53
+ ## Development
54
+
55
+ 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.
56
+
57
+ 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).
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/coyosoftware/paghiper. 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.
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
66
+
67
+ ## Code of Conduct
68
+
69
+ Everyone interacting in the Paghiper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coyosoftware/paghiper/blob/master/CODE_OF_CONDUCT.md).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'paghiper'
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__)
@@ -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,25 @@
1
+ require 'paghiper/version'
2
+ require 'active_support/core_ext/hash/indifferent_access'
3
+
4
+ module Paghiper
5
+ autoload :Transaction, 'paghiper/transaction'
6
+ autoload :Client, 'paghiper/client'
7
+
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.configure
13
+ self.configuration ||= Configuration.new
14
+
15
+ yield(configuration)
16
+ end
17
+
18
+ class Configuration
19
+ attr_accessor :api_key, :http_debug
20
+
21
+ def initialize
22
+ @http_debug = false
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'httparty'
2
+
3
+ module Paghiper
4
+ class MissingApiKeyError < StandardError; end
5
+
6
+ class Client
7
+ include HTTParty
8
+
9
+ base_uri 'https://api.paghiper.com'
10
+ headers 'Accept' => 'application/json', 'Content-Type' => 'application/json'
11
+ debug_output $stdout if Paghiper.configuration && Paghiper.configuration.http_debug
12
+
13
+ class << self
14
+ def create_transaction(transaction)
15
+ peform_action!(:post, '/transaction/create', body: prepare_body(transaction))
16
+ end
17
+
18
+ private
19
+
20
+ def prepare_body(data)
21
+ data.merge(apiKey: Paghiper.configuration.api_key).to_json
22
+ end
23
+
24
+ def peform_action!(action_name, url, options = {})
25
+ raise(MissingTokenError, 'Informe a api key para realizar a autenticação') if Paghiper.configuration.api_key.nil? || Paghiper.configuration.api_key.empty?
26
+
27
+ send(action_name, url, options)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module Paghiper
2
+ class Transaction
3
+ class << self
4
+ def create(transaction)
5
+ response = Paghiper::Client.create_transaction(transaction)
6
+ hash = JSON.parse(response.body).with_indifferent_access
7
+
8
+ return hash['create_request']
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Paghiper
2
+ VERSION = '0.1.1'.freeze
3
+ end
@@ -0,0 +1,12 @@
1
+ module Paghiper
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __dir__)
5
+ desc 'Creates the PagHiper initializer'
6
+
7
+ def copy_initializer
8
+ template 'paghiper.rb', 'config/initializers/paghiper.rb'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ Paghiper.configure do |config|
2
+ config.api_key = 'SUA API KEY'
3
+ config.http_debug = true
4
+ end
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'paghiper/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'paghiper'
7
+ spec.version = Paghiper::VERSION
8
+ spec.authors = ['Coyô Software']
9
+ spec.email = ['ti@coyo.com.br']
10
+
11
+ spec.summary = 'Gem para integração com a API de geração de boleto do PAGHIPER'
12
+ spec.description = 'Gem para integração com a API de geração de boleto do PAGHIPER'
13
+ spec.homepage = 'https://github.com/coyosoftware/paghiper'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.15'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'simplecov', '~> 0.16'
27
+ spec.add_development_dependency 'webmock', '~> 3.4'
28
+
29
+ spec.add_dependency 'httparty', '>= 0.14'
30
+ spec.add_dependency 'activesupport', '>= 3.0'
31
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paghiper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Coyô Software
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0.14'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0.14'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: Gem para integração com a API de geração de boleto do PAGHIPER
112
+ email:
113
+ - ti@coyo.com.br
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/paghiper.rb
129
+ - lib/paghiper/client.rb
130
+ - lib/paghiper/transaction.rb
131
+ - lib/paghiper/version.rb
132
+ - lib/rails/generators/paghiper/install_generator.rb
133
+ - lib/rails/generators/templates/paghiper.rb
134
+ - paghiper.gemspec
135
+ homepage: https://github.com/coyosoftware/paghiper
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.7.6
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Gem para integração com a API de geração de boleto do PAGHIPER
159
+ test_files: []