nasp 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f20dc9bf00e34a5a79025c0233a4c2c442e516f
4
+ data.tar.gz: ee4cea20866f9fa1f83a5ef7dc6d2d0b15b265a5
5
+ SHA512:
6
+ metadata.gz: 9dae4947af103f1ebd5d1a97a5ea62fb42c409afcbfb2a8b0209d726c4d07ba7cc113832e86da1930fd7edfaa02f7b84f4defcf6938313f27f282624e4859699
7
+ data.tar.gz: 0163ffa72a8a4f75c541acc5d6a9a5fb1ca26a5fcd398838c762d46bdadc45b44fe9d0bad172bf594eab5ccf7aea393fd03ca3c3ad8143928455aefd9a44d8b4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in new_gem.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nasp (0.0.1)
5
+ builder
6
+ httparty
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ builder (3.1.4)
12
+ httparty (0.12.0)
13
+ json (~> 1.8)
14
+ multi_xml (>= 0.5.2)
15
+ json (1.8.1)
16
+ multi_xml (0.5.5)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ nasp!
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task default: :spec
Binary file
@@ -0,0 +1,87 @@
1
+ module Nasp
2
+ class InstructionQuery
3
+ include HTTParty
4
+ debug_output $stderr
5
+
6
+ attr_reader :token, :response, :payment
7
+ base_uri Rails.env == "development" ? "https://desenvolvedor.moip.com.br/sandbox" : "https://www.moip.com.br"
8
+
9
+ def initialize(token)
10
+ @token = token
11
+ @auth = {
12
+ username: Nasp.token,
13
+ password: Nasp.key
14
+ }
15
+ end
16
+
17
+ def api_call
18
+ options = {:basic_auth => @auth}
19
+ url = "/ws/alpha/ConsultarInstrucao/#{@token}"
20
+ @response = self.class.get(url, options)
21
+ @payment = last_payment
22
+ end
23
+
24
+ def result
25
+ @response["ConsultarTokenResponse"]["RespostaConsultar"]["Autorizacao"]
26
+ end
27
+
28
+ def buyer_name
29
+ result["Pagador"]["Nome"]
30
+ end
31
+
32
+ def buyer_email
33
+ result["Pagador"]["Email"]
34
+ end
35
+
36
+ def date
37
+ DateTime.parse(@payment["Data"])
38
+ end
39
+
40
+ def escrow_end_date
41
+ DateTime.parse(@payment["DataCredito"])
42
+ end
43
+
44
+ def gross_amount
45
+ @payment["TotalPago"]["__content__"]
46
+ end
47
+
48
+ def fee_amount
49
+ @payment["TaxaMoIP"]["__content__"]
50
+ end
51
+
52
+ def net_amount
53
+ @payment["ValorLiquido"]["__content__"]
54
+ end
55
+
56
+ def payment_type
57
+ @payment["FormaPagamento"]
58
+ end
59
+
60
+ def payment_flag
61
+ @payment["InstituicaoPagamento"]
62
+ end
63
+
64
+ def status
65
+ @payment["Status"]["Tipo"]
66
+ end
67
+
68
+ def id
69
+ @payment["CodigoMoIP"]
70
+ end
71
+
72
+ private
73
+ def last_payment
74
+ payment = result["Pagamento"]
75
+ if payment.kind_of?(Hash)
76
+ @payment = payment
77
+ else
78
+ @payment = payment.first
79
+ payment.each do |r|
80
+ payment_date = DateTime.parse(r["Data"])
81
+ @payment = r if payment_date > self.date
82
+ end
83
+ end
84
+ @payment
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,3 @@
1
+ module Nasp
2
+ VERSION = '0.0.2'
3
+ end
data/lib/nasp.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'nasp/instruction_query'
4
+
5
+ module Nasp
6
+ end
data/nasp-0.0.1.gem ADDED
Binary file
data/nasp.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require 'nasp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nasp"
8
+ spec.version = Nasp::VERSION
9
+ spec.authors = ["Cirdes Borges Henrique Filho"]
10
+ spec.email = ["cirdes@eventick.com.br"]
11
+ spec.description = %q{Handling Moip NASP notificaiton}
12
+ spec.summary = %q{Easy way to receive Moip notification}
13
+ spec.homepage = "https://github.com/eventick/nasp"
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_dependency "activemodel"
22
+ spec.add_dependency "builder"
23
+ spec.add_dependency "httparty"
24
+ # spec.add_development_dependency "bundler", "~> 1.3"
25
+ # spec.add_development_dependency "mocha"
26
+ # spec.add_development_dependency "rake"
27
+ # spec.add_development_dependency "rdoc", "~> 3.12"
28
+ # spec.add_development_dependency "vcr"
29
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nasp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Cirdes Borges Henrique Filho
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Handling Moip NASP notificaiton
42
+ email:
43
+ - cirdes@eventick.com.br
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - README.md
51
+ - Rakefile
52
+ - lib/nasp.rb
53
+ - lib/nasp/.DS_Store
54
+ - lib/nasp/instruction_query.rb
55
+ - lib/nasp/version.rb
56
+ - nasp-0.0.1.gem
57
+ - nasp.gemspec
58
+ homepage: https://github.com/eventick/nasp
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.0.5
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Easy way to receive Moip notification
82
+ test_files: []
83
+ has_rdoc: