mercadobitcoin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c364175f505ed056c73284b173f81b19772a960c
4
+ data.tar.gz: 84e3d863de1ed00c1bb942ac29396c15034d4862
5
+ SHA512:
6
+ metadata.gz: 6e8f1d17f562fc5eed4eae4dbbdbb17d25f5a71c8fcaad25773ab59c429a727865fd0f75d536cebd6bc09eb1fd3bd93642243ab673547a841e42e8ac3cb24842
7
+ data.tar.gz: 31da27fa5a03e604c9f4f07c3aee002949753d113c2cc0e2bcb8a0ad6af653b9e1f363598b26d4748e1f4a38a8d24c38fabe1b94e985d7f7567d3978cca96633
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ spec/credentials.yaml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mercadobitcoin.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bruno Buccolo
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.
@@ -0,0 +1,31 @@
1
+ # Mercadobitcoin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mercadobitcoin'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mercadobitcoin
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/mercadobitcoin/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,49 @@
1
+ require "mercadobitcoin/version"
2
+ require 'httparty'
3
+ require 'hmac-sha2'
4
+ require 'active_support/core_ext/hash/indifferent_access'
5
+
6
+ module MercadoBitcoin
7
+ class << self
8
+ attr_reader :api_key, :api_secret, :pin
9
+
10
+ BASE_URL = "https://www.mercadobitcoin.com.br/tapi/".freeze
11
+
12
+ def balance
13
+ current_tonce = tonce
14
+
15
+ method = "getInfo"
16
+ headers = {
17
+ "Content-type" => "application/x-www-form-urlencoded",
18
+ "Key" => api_key,
19
+ "Sign" => signature(method, current_tonce)
20
+ }
21
+
22
+ HTTParty.post(BASE_URL, {
23
+ body: {
24
+ method: method,
25
+ tonce: current_tonce,
26
+ },
27
+ headers: headers
28
+ })
29
+ end
30
+
31
+ def tonce
32
+ Time.now.to_i
33
+ end
34
+
35
+ def authenticate!(credentials)
36
+ credentials = credentials.with_indifferent_access
37
+
38
+ @api_key = credentials[:api_key]
39
+ @api_secret = credentials[:api_secret]
40
+ @pin = credentials[:pin]
41
+ end
42
+
43
+ def signature(method, current_tonce)
44
+ message = [method, pin, current_tonce].join(":")
45
+
46
+ hash = HMAC::SHA512.hexdigest(api_secret, message)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module MercadoBitcoin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mercadobitcoin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mercadobitcoin"
8
+ spec.version = MercadoBitcoin::VERSION
9
+ spec.authors = ["Bruno Buccolo"]
10
+ spec.email = ["bruno.buccolo@gmail.com"]
11
+ spec.summary = %q{Unofficial wrapper for mercadobitcoin.com.br}
12
+ spec.description = %q{Unofficial wrapper for the MercadoBitcoin exchange API}
13
+ spec.homepage = "https://github.com/buccolo/mercadobitcoin"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "rack-test", "~> 0.6"
25
+ spec.add_development_dependency "pry-byebug", "~> 2.0"
26
+
27
+ spec.add_dependency "httparty", "~> 0.13"
28
+ spec.add_dependency "ruby-hmac", "~> 0.4"
29
+ spec.add_dependency "activesupport", "~> 4.1"
30
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe BitcoinToYou do
4
+ subject { described_class }
5
+
6
+ describe '.ticker' do
7
+ xit 'returns current ticker information for btc' do
8
+ ticker = subject.ticker
9
+ keys = ["buy", "date", "high", "last", "low", "sell", "vol"]
10
+
11
+ keys.each do |key|
12
+ expect(ticker[key]).to be
13
+ end
14
+ end
15
+ end
16
+
17
+ describe '.balance' do
18
+ it 'works' do
19
+ expect(subject.balance).to eq 123
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ api_key: <<KEY>>
2
+ api_secret: <<SECRET>>
3
+ pin: <<PIN>>
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe MercadoBitcoin do
4
+ subject { described_class }
5
+
6
+ before do
7
+ described_class.authenticate! YAML.load_file("./spec/credentials.yaml")
8
+ end
9
+
10
+ describe '.balance' do
11
+ it 'returns balance information' do
12
+ expect(subject.balance["return"]["funds"]["btc"]).to be
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rack/test'
4
+
5
+ require 'rspec'
6
+ require 'pry-byebug'
7
+
8
+ Bundler.require(:default, :test)
9
+
10
+ require './lib/mercadobitcoin'
11
+
12
+ RSpec.configure do |config|
13
+ config.include Rack::Test::Methods
14
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mercadobitcoin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Buccolo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-08 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
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.13'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-hmac
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.1'
125
+ description: Unofficial wrapper for the MercadoBitcoin exchange API
126
+ email:
127
+ - bruno.buccolo@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - lib/mercadobitcoin.rb
138
+ - lib/mercadobitcoin/version.rb
139
+ - mercadobitcoin.gemspec
140
+ - spec/bitcointoyou/bitcointoyou_spec.rb
141
+ - spec/credentials.yaml.sample
142
+ - spec/mercadobitcoin/mercadobitcoin_spec.rb
143
+ - spec/spec_helper.rb
144
+ homepage: https://github.com/buccolo/mercadobitcoin
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.2.2
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Unofficial wrapper for mercadobitcoin.com.br
168
+ test_files:
169
+ - spec/bitcointoyou/bitcointoyou_spec.rb
170
+ - spec/credentials.yaml.sample
171
+ - spec/mercadobitcoin/mercadobitcoin_spec.rb
172
+ - spec/spec_helper.rb