moip_v2 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: 593707f9ef86a1b8e4eea1e53a37f9e698eb5188
4
+ data.tar.gz: 901f184321f66beee81d21b3f148b7c8ff4f3c94
5
+ SHA512:
6
+ metadata.gz: c59b07e38eea1f96910c6ab577a89344b2ee59abe87568ba33de22e3583050a3642dd1248ed5aaa967f159ef7d3d21f43188fb3d4f4bae425f488b5b716ddde0
7
+ data.tar.gz: f0d8eb781ae9ecc4260e4c710c356b1ad70b2cf9ddc5c5588506591d6f53cbc483017513fb75acb7f42701b70e40964d1ed8f36e10935f1a2a2c52fb72c3c46d
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in moip_v2.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Diogo Biazus
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # MoipV2 [![Build Status](https://travis-ci.org/diogob/moip_v2.png)](https://travis-ci.org/diogob/moip_v2) [![Code Climate](https://codeclimate.com/github/diogob/moip_v2.png)](https://codeclimate.com/github/diogob/moip_v2)
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'moip_v2'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install moip_v2
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -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
data/lib/moip_v2.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "moip_v2/version"
2
+ require "moip_v2/configuration"
3
+ require "active_resource"
4
+ require "moip_v2/base"
5
+ require "moip_v2/refund"
6
+ require "moip_v2/payment"
7
+ require "moip_v2/payment_detail"
8
+ require "moip_v2/order"
9
+
10
+ module MoipV2
11
+ extend Configuration
12
+ end
@@ -0,0 +1,14 @@
1
+ module MoipV2
2
+ class Base < ActiveResource::Base
3
+ def self.user
4
+ MoipV2.api_token
5
+ end
6
+
7
+ def self.password
8
+ MoipV2.api_key
9
+ end
10
+
11
+ self.include_format_in_path = false
12
+ end
13
+ end
14
+
@@ -0,0 +1,49 @@
1
+ module MoipV2
2
+ module Configuration
3
+ VALID_CONNECTION_KEYS = [:endpoint, :user_agent, :method].freeze
4
+ VALID_OPTIONS_KEYS = [:api_token, :api_key].freeze
5
+ VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
6
+
7
+ DEFAULT_ENDPOINT = 'https://test.moip.com.br/v2/'
8
+ DEFAULT_METHOD = :get
9
+ DEFAULT_USER_AGENT = "Awesome API Ruby Gem #{MoipV2::VERSION}".freeze
10
+
11
+ DEFAULT_API_TOKEN = nil
12
+ DEFAULT_API_KEY = nil
13
+
14
+ # Build accessor methods for every config options so we can do this, for example:
15
+ # Awesome.format = <img src="http://s2.wp.com/wp-includes/images/smilies/icon_mad.gif?m=1129645325g" alt=":x" class="wp-smiley"> ml
16
+ attr_accessor *VALID_CONFIG_KEYS
17
+
18
+ # Make sure we have the default values set when we get 'extended'
19
+ def self.extended(base)
20
+ base.reset
21
+ end
22
+
23
+ def configure
24
+ yield self if block_given?
25
+ Base.site = self.endpoint
26
+ Refund.site = "#{Base.site}payments/:payment_id"
27
+ Payment.site = "#{Base.site}orders/:order_id/"
28
+ end
29
+
30
+ def test_mode
31
+ require "moip_v2/debug_requests"
32
+ self.endpoint = DEFAULT_ENDPOINT
33
+ end
34
+
35
+ def options
36
+ Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
37
+ end
38
+
39
+ def reset
40
+ self.endpoint = DEFAULT_ENDPOINT
41
+ self.method = DEFAULT_METHOD
42
+ self.user_agent = DEFAULT_USER_AGENT
43
+
44
+ self.api_token = DEFAULT_API_TOKEN
45
+ self.api_key = DEFAULT_API_KEY
46
+ end
47
+
48
+ end # Configuration
49
+ end
@@ -0,0 +1,19 @@
1
+ module ActiveResource
2
+ class Connection
3
+ def debug_request(method, path, *arguments)
4
+ puts "#{method} #{path}\n\n#{arguments.inspect}"
5
+ old_request(method, path, *arguments)
6
+ end
7
+
8
+ alias :old_request :request
9
+ alias :request :debug_request
10
+
11
+ def debug_response(response)
12
+ puts response.inspect
13
+ old_handle_response(response)
14
+ end
15
+
16
+ alias :old_handle_response :handle_response
17
+ alias :handle_response :debug_response
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module MoipV2
2
+ class Order < Base
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module MoipV2
2
+ class Payment < Base
3
+ def order_id=(order_id)
4
+ @prefix_options = { order_id: order_id }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module MoipV2
2
+ class PaymentDetail < Base
3
+ self.element_name = 'payments'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module MoipV2
2
+ class Refund < Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module MoipV2
2
+ VERSION = "0.0.1"
3
+ end
data/moip_v2.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 'moip_v2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "moip_v2"
8
+ spec.version = MoipV2::VERSION
9
+ spec.authors = ["Diogo Biazus"]
10
+ spec.email = ["diogob@gmail.com"]
11
+ spec.description = %q{Ruby wrapper to MoIP v2 API}
12
+ spec.summary = %q{Ruby wrapper to MoIP v2 API}
13
+ spec.homepage = "https://github.com/diogob/moip_v2"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_runtime_dependency "activeresource"
26
+ end
data/spec/base_spec.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoipV2::Base do
4
+ describe ".user" do
5
+ subject{ MoipV2::Base.user }
6
+ before{ MoipV2.api_token = 'api_token' }
7
+ it{ should eq MoipV2.api_token }
8
+ end
9
+
10
+ describe ".password" do
11
+ subject{ MoipV2::Base.password }
12
+ before{ MoipV2.api_key = 'api_key' }
13
+ it{ should eq MoipV2.api_key }
14
+ end
15
+ end
16
+
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoipV2::Configuration do
4
+ before do
5
+ MoipV2.reset
6
+ end
7
+
8
+ MoipV2::Configuration::VALID_CONFIG_KEYS.each do |key|
9
+ describe ".#{key}" do
10
+ it 'should return the default value' do
11
+ expect(MoipV2.send(key)).to eq MoipV2::Configuration.const_get("DEFAULT_#{key.upcase}")
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '.configure' do
17
+
18
+ it "should set Refund.site using API endpoint and payments path" do
19
+ MoipV2.configure
20
+ expect(MoipV2::Refund.site.to_s).to eq "#{MoipV2.endpoint}payments/:payment_id"
21
+ end
22
+
23
+ it "should set Base.site using API endpoint" do
24
+ MoipV2.configure
25
+ expect(MoipV2::Base.site.to_s).to eq MoipV2.endpoint
26
+ end
27
+
28
+ MoipV2::Configuration::VALID_CONFIG_KEYS.each do |key|
29
+ it "should set the #{key}" do
30
+ MoipV2.configure do |config|
31
+ config.send("#{key}=", key)
32
+ expect(MoipV2.send(key)).to eq key
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoipV2 do
4
+ it 'should have a version number' do
5
+ expect(MoipV2::VERSION).to_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'moip_v2'
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moip_v2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Diogo Biazus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-20 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activeresource
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby wrapper to MoIP v2 API
70
+ email:
71
+ - diogob@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/moip_v2.rb
84
+ - lib/moip_v2/base.rb
85
+ - lib/moip_v2/configuration.rb
86
+ - lib/moip_v2/debug_requests.rb
87
+ - lib/moip_v2/order.rb
88
+ - lib/moip_v2/payment.rb
89
+ - lib/moip_v2/payment_detail.rb
90
+ - lib/moip_v2/refund.rb
91
+ - lib/moip_v2/version.rb
92
+ - moip_v2.gemspec
93
+ - spec/base_spec.rb
94
+ - spec/configuration_spec.rb
95
+ - spec/moip_v2_spec.rb
96
+ - spec/spec_helper.rb
97
+ homepage: https://github.com/diogob/moip_v2
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Ruby wrapper to MoIP v2 API
121
+ test_files:
122
+ - spec/base_spec.rb
123
+ - spec/configuration_spec.rb
124
+ - spec/moip_v2_spec.rb
125
+ - spec/spec_helper.rb