paytunia 0.1alpha

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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Paymium SAS
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ Paytunia
2
+ =
3
+
4
+ The official Ruby gem to integrate your app with [Paytunia](https://paytunia.com).
data/bin/paytunia ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Trap interrupts to quit cleanly. See
4
+ # https://twitter.com/mitchellh/status/283014103189053442
5
+ Signal.trap("INT") { exit 1 }
6
+
7
+ require 'paytunia'
8
+
9
+ Paytunia.cli!
10
+
11
+ ARGV.each do |command|
12
+ puts Paytunia::Connection.send(command)
13
+ end
data/lib/paytunia.rb ADDED
@@ -0,0 +1,5 @@
1
+ Dir[File.dirname(__FILE__) + '/paytunia/api/**.rb'].each do |file|
2
+ require file
3
+ end
4
+
5
+ require 'paytunia/connection'
@@ -0,0 +1,12 @@
1
+ module Paytunia
2
+ module Api
3
+ module Account
4
+
5
+ # Returns the list of account operations
6
+ def get_ledger
7
+ token.get('/api/v1/account_operations').body
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ module Paytunia
2
+ module Api
3
+ module Trading
4
+
5
+ # Returns the active trade orders (pending_execution, active, or insufficient_funds)
6
+ def list_active_orders
7
+ token.get('/api/v1/trade_orders/active').body
8
+ end
9
+
10
+ # Returns all orders, ever
11
+ def list_orders
12
+ token.get('/api/v1/trade_orders').body
13
+ end
14
+
15
+ # Returns the ticker
16
+ def get_ticker
17
+ get('/api/v1/ticker')
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,65 @@
1
+ require 'oauth2'
2
+ require 'httparty'
3
+ require 'singleton'
4
+ require 'io/console'
5
+
6
+ module Paytunia
7
+
8
+ @@cli = false
9
+
10
+ def self.cli
11
+ @@cli
12
+ end
13
+
14
+ def self.cli!
15
+ @@cli = true
16
+ end
17
+
18
+ class Connection
19
+
20
+ include Singleton
21
+
22
+ include HTTParty
23
+
24
+ include Paytunia::Api::Account
25
+ include Paytunia::Api::Trading
26
+
27
+ APP_ID = '6fcf1c32f6e14cd773a7a6640832bdbf83a5b2b8d4382e839c6aff83a8f1bb3b'
28
+ APP_SECRET = '55554ecad5627f0465034c4a116e59a38d9c3ab272487a18404078ccc0b64798'
29
+
30
+ SITE = 'https://bitcoin-central.net'
31
+
32
+ def get(url)
33
+ self.class.get(SITE + url).body
34
+ end
35
+
36
+ def token
37
+ @token ||= connect
38
+ end
39
+
40
+ def connect(credentials = nil)
41
+ unless credentials
42
+ if Paytunia.cli
43
+ print 'Account ID: '
44
+ username = $stdin.gets.chomp
45
+
46
+ print 'Password: '
47
+ password = STDIN.noecho { $stdin.gets }.chomp
48
+ print "\n"
49
+ else
50
+ raise 'No credentials provided, unable to request them interactively'
51
+ end
52
+ end
53
+
54
+ client = OAuth2::Client.new(APP_ID, APP_SECRET,
55
+ site: SITE,
56
+ ssl: { ca_file: File.dirname(__FILE__) + '/../../certs/ca-certificates.crt' })
57
+
58
+ @token = client.password.get_token(username, password, scope: 'read trade merchant')
59
+ end
60
+
61
+ def self.method_missing(method, *args, &block)
62
+ instance.respond_to?(method) ? instance.send(method, *args, &block) : super
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Paytunia
2
+ VERSION = "0.1alpha"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paytunia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1alpha
5
+ prerelease: 3
6
+ platform: ruby
7
+ authors:
8
+ - Alexis DENEUX
9
+ - David FRANCOIS
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-02-20 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: oauth2
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 0.9.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: httparty
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: Supports all API calls, HTTP Basic and OAuth2 authentication
64
+ email:
65
+ - support@paytunia.com
66
+ executables:
67
+ - paytunia
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - bin/paytunia
72
+ - lib/paytunia/api/account.rb
73
+ - lib/paytunia/api/trading.rb
74
+ - lib/paytunia/connection.rb
75
+ - lib/paytunia/version.rb
76
+ - lib/paytunia.rb
77
+ - LICENSE
78
+ - README.md
79
+ homepage: https://paytunia.com/
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.6
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.24
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Easily integrate your app with Paytunia.com
103
+ test_files: []