luno 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +69 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +114 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/luno.rb +28 -0
- data/lib/luno/accounts.rb +8 -0
- data/lib/luno/beneficiaries.rb +5 -0
- data/lib/luno/client.rb +108 -0
- data/lib/luno/lightning.rb +5 -0
- data/lib/luno/markets.rb +8 -0
- data/lib/luno/orders.rb +5 -0
- data/lib/luno/other_data.rb +103 -0
- data/lib/luno/quotes.rb +5 -0
- data/lib/luno/receiving.rb +5 -0
- data/lib/luno/sending.rb +5 -0
- data/lib/luno/streaming.rb +5 -0
- data/lib/luno/transactions.rb +5 -0
- data/lib/luno/version.rb +3 -0
- data/lib/luno/withdrawals.rb +5 -0
- data/luno.gemspec +39 -0
- metadata +239 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: daa749234c20ac9ba06398b5c4bd8e5c3e14af593411877ded14fd31d42d0aaf
|
4
|
+
data.tar.gz: 4134f4e339b3f39f0a593b46b94baf665479a5e5681de2a0b57e46dcc0ba38a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b90a4e741c23e3cb14a45ccc7234ca4672a9d192af015d45a3796651ee52cdbf2739980aafa36318d88c5fef7ce711d31de7a69ed2588b35a4fb3e06ed5662f2
|
7
|
+
data.tar.gz: 3c07483225243bdaf7ef880f37802fea9b0bd24233bc5773be7cd9898218054b6b8151bb9228d4df168dab6ea6652484dc2a25f4c3455cc7de6308981a45504f
|
data/.gitignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/db/*.sqlite3
|
5
|
+
/db/*.sqlite3-journal
|
6
|
+
/db/*.sqlite3-[0-9]*
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/spec/tmp
|
10
|
+
*.orig
|
11
|
+
rerun.txt
|
12
|
+
pickle-email-*.html
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
21
|
+
config/initializers/secret_token.rb
|
22
|
+
config/master.key
|
23
|
+
|
24
|
+
# Only include if you have production secrets in this file, which is no longer a Rails default
|
25
|
+
# config/secrets.yml
|
26
|
+
|
27
|
+
# dotenv
|
28
|
+
# TODO Comment out this rule if environment variables can be committed
|
29
|
+
.env
|
30
|
+
|
31
|
+
## Environment normalization:
|
32
|
+
/.bundle
|
33
|
+
/vendor/bundle
|
34
|
+
|
35
|
+
# these should all be checked in to normalize the environment:
|
36
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
37
|
+
|
38
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
39
|
+
.rvmrc
|
40
|
+
|
41
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
42
|
+
/vendor/assets/bower_components
|
43
|
+
*.bowerrc
|
44
|
+
bower.json
|
45
|
+
|
46
|
+
# Ignore pow environment settings
|
47
|
+
.powenv
|
48
|
+
|
49
|
+
# Ignore Byebug command history file.
|
50
|
+
.byebug_history
|
51
|
+
|
52
|
+
# Ignore node_modules
|
53
|
+
node_modules/
|
54
|
+
|
55
|
+
# Ignore precompiled javascript packs
|
56
|
+
/public/packs
|
57
|
+
/public/packs-test
|
58
|
+
/public/assets
|
59
|
+
|
60
|
+
# Ignore yarn files
|
61
|
+
/yarn-error.log
|
62
|
+
yarn-debug.log*
|
63
|
+
.yarn-integrity
|
64
|
+
|
65
|
+
# Ignore uploaded files in development
|
66
|
+
/storage/*
|
67
|
+
!/storage/.keep
|
68
|
+
|
69
|
+
*.gem
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 contact@jasonchalom.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
data/Gemfile.lock
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
luno (0.1.0)
|
5
|
+
active_attr (~> 0.15)
|
6
|
+
httparty (~> 0.18)
|
7
|
+
nokogiri (~> 1.10.9)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (6.0.2.2)
|
13
|
+
actionview (= 6.0.2.2)
|
14
|
+
activesupport (= 6.0.2.2)
|
15
|
+
rack (~> 2.0, >= 2.0.8)
|
16
|
+
rack-test (>= 0.6.3)
|
17
|
+
rails-dom-testing (~> 2.0)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
+
actionview (6.0.2.2)
|
20
|
+
activesupport (= 6.0.2.2)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubi (~> 1.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
+
active_attr (0.15.0)
|
26
|
+
actionpack (>= 3.0.2, < 6.1)
|
27
|
+
activemodel (>= 3.0.2, < 6.1)
|
28
|
+
activesupport (>= 3.0.2, < 6.1)
|
29
|
+
activemodel (6.0.2.2)
|
30
|
+
activesupport (= 6.0.2.2)
|
31
|
+
activesupport (6.0.2.2)
|
32
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
33
|
+
i18n (>= 0.7, < 2)
|
34
|
+
minitest (~> 5.1)
|
35
|
+
tzinfo (~> 1.1)
|
36
|
+
zeitwerk (~> 2.2)
|
37
|
+
addressable (2.7.0)
|
38
|
+
public_suffix (>= 2.0.2, < 5.0)
|
39
|
+
ansi (1.5.0)
|
40
|
+
builder (3.2.4)
|
41
|
+
coderay (1.1.2)
|
42
|
+
concurrent-ruby (1.1.6)
|
43
|
+
crack (0.4.3)
|
44
|
+
safe_yaml (~> 1.0.0)
|
45
|
+
crass (1.0.6)
|
46
|
+
erubi (1.9.0)
|
47
|
+
hashdiff (1.0.1)
|
48
|
+
httparty (0.18.0)
|
49
|
+
mime-types (~> 3.0)
|
50
|
+
multi_xml (>= 0.5.2)
|
51
|
+
i18n (1.8.2)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
loofah (2.4.0)
|
54
|
+
crass (~> 1.0.2)
|
55
|
+
nokogiri (>= 1.5.9)
|
56
|
+
method_source (1.0.0)
|
57
|
+
mime-types (3.3.1)
|
58
|
+
mime-types-data (~> 3.2015)
|
59
|
+
mime-types-data (3.2019.1009)
|
60
|
+
mini_portile2 (2.4.0)
|
61
|
+
minitest (5.14.0)
|
62
|
+
minitest-focus (1.1.2)
|
63
|
+
minitest (>= 4, < 6)
|
64
|
+
minitest-reporters (1.4.2)
|
65
|
+
ansi
|
66
|
+
builder
|
67
|
+
minitest (>= 5.0)
|
68
|
+
ruby-progressbar
|
69
|
+
mocha (1.11.2)
|
70
|
+
multi_xml (0.6.0)
|
71
|
+
nokogiri (1.10.9)
|
72
|
+
mini_portile2 (~> 2.4.0)
|
73
|
+
pry (0.13.0)
|
74
|
+
coderay (~> 1.1)
|
75
|
+
method_source (~> 1.0)
|
76
|
+
public_suffix (4.0.3)
|
77
|
+
rack (2.2.2)
|
78
|
+
rack-test (1.1.0)
|
79
|
+
rack (>= 1.0, < 3)
|
80
|
+
rails-dom-testing (2.0.3)
|
81
|
+
activesupport (>= 4.2.0)
|
82
|
+
nokogiri (>= 1.6)
|
83
|
+
rails-html-sanitizer (1.3.0)
|
84
|
+
loofah (~> 2.3)
|
85
|
+
rake (10.5.0)
|
86
|
+
ruby-progressbar (1.10.1)
|
87
|
+
safe_yaml (1.0.5)
|
88
|
+
thread_safe (0.3.6)
|
89
|
+
timecop (0.9.1)
|
90
|
+
tzinfo (1.2.6)
|
91
|
+
thread_safe (~> 0.1)
|
92
|
+
webmock (3.8.3)
|
93
|
+
addressable (>= 2.3.6)
|
94
|
+
crack (>= 0.3.2)
|
95
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
96
|
+
zeitwerk (2.3.0)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
bundler (~> 1.17)
|
103
|
+
luno!
|
104
|
+
minitest (~> 5.0)
|
105
|
+
minitest-focus (~> 1.1.2)
|
106
|
+
minitest-reporters (~> 1.4.2)
|
107
|
+
mocha (~> 1.11.2)
|
108
|
+
pry (~> 0.13)
|
109
|
+
rake (~> 10.0)
|
110
|
+
timecop (~> 0.9.1)
|
111
|
+
webmock (~> 3.8.3)
|
112
|
+
|
113
|
+
BUNDLED WITH
|
114
|
+
1.17.3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Jason Chalom
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 trex22
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Luno
|
2
|
+
|
3
|
+
This is a client for the Luno API. See: https://www.luno.com/en/developers/api
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'luno'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install luno
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
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).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/trex22/luno. 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.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
38
|
+
|
39
|
+
## Code of Conduct
|
40
|
+
|
41
|
+
Everyone interacting in the Luno: project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/trex22/luno/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "luno"
|
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
|
data/bin/setup
ADDED
data/lib/luno.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
require 'luno/version'
|
5
|
+
|
6
|
+
# Endpoints
|
7
|
+
require 'luno/accounts'
|
8
|
+
require 'luno/beneficiaries'
|
9
|
+
require 'luno/markets'
|
10
|
+
require 'luno/orders'
|
11
|
+
require 'luno/quotes'
|
12
|
+
require 'luno/receiving'
|
13
|
+
require 'luno/sending'
|
14
|
+
require 'luno/transactions'
|
15
|
+
require 'luno/withdrawals'
|
16
|
+
|
17
|
+
# Beta Endpoints
|
18
|
+
require 'luno/lightning'
|
19
|
+
require 'luno/streaming'
|
20
|
+
|
21
|
+
# Custom Endpoints
|
22
|
+
require 'luno/other_data'
|
23
|
+
|
24
|
+
require 'luno/client'
|
25
|
+
|
26
|
+
module Luno
|
27
|
+
class Error < StandardError; end
|
28
|
+
end
|
data/lib/luno/client.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
module Luno
|
2
|
+
class Client
|
3
|
+
# Endpoints
|
4
|
+
include ::Luno::Accounts
|
5
|
+
include ::Luno::Beneficiaries
|
6
|
+
include ::Luno::Markets
|
7
|
+
include ::Luno::Orders
|
8
|
+
include ::Luno::Quotes
|
9
|
+
include ::Luno::Receiving
|
10
|
+
include ::Luno::Sending
|
11
|
+
include ::Luno::Transactions
|
12
|
+
include ::Luno::Withdrawals
|
13
|
+
|
14
|
+
# Beta Endpoints
|
15
|
+
include ::Luno::Lightning
|
16
|
+
include ::Luno::Streaming
|
17
|
+
|
18
|
+
# Custom Endpoints
|
19
|
+
include ::Luno::OtherData
|
20
|
+
|
21
|
+
attr_reader :key, :secret, :base_path, :port
|
22
|
+
|
23
|
+
def initialize(key:, secret:, base_path: 'https://api.mybitx.com/api/1', port: 80)
|
24
|
+
@key = key
|
25
|
+
@secret = secret
|
26
|
+
@base_path = base_path
|
27
|
+
@port = port
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.compatible_api_version
|
31
|
+
'v1'
|
32
|
+
end
|
33
|
+
|
34
|
+
# This is the version of the API docs this client was built off-of
|
35
|
+
def self.api_version
|
36
|
+
'v1 2020-02-24'
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def unauthorised_and_send(http_method:, path:, payload: {})
|
42
|
+
start_time = get_micro_second_time
|
43
|
+
|
44
|
+
response = HTTParty.send(
|
45
|
+
http_method.to_sym,
|
46
|
+
construct_base_path(path),
|
47
|
+
body: payload,
|
48
|
+
headers: { 'Content-Type': 'application/json' },
|
49
|
+
port: port,
|
50
|
+
format: :json
|
51
|
+
)
|
52
|
+
|
53
|
+
end_time = get_micro_second_time
|
54
|
+
construct_response_obejct(response, start_time, end_time)
|
55
|
+
end
|
56
|
+
|
57
|
+
def authorise_and_send(http_method:, path:, payload: {})
|
58
|
+
auth = {username: key, password: secret}
|
59
|
+
|
60
|
+
start_time = get_micro_second_time
|
61
|
+
|
62
|
+
response = HTTParty.send(
|
63
|
+
http_method.to_sym,
|
64
|
+
construct_base_path(path),
|
65
|
+
body: payload,
|
66
|
+
headers: { 'Content-Type': 'application/json' },
|
67
|
+
port: port,
|
68
|
+
basic_auth: auth,
|
69
|
+
format: :json
|
70
|
+
)
|
71
|
+
|
72
|
+
end_time = get_micro_second_time
|
73
|
+
construct_response_obejct(response, start_time, end_time)
|
74
|
+
end
|
75
|
+
|
76
|
+
def construct_response_obejct(response, start_time, end_time)
|
77
|
+
if response.ok?
|
78
|
+
response.to_json.merge({
|
79
|
+
metadata: construct_metadata(start_time, end_time)
|
80
|
+
})
|
81
|
+
else
|
82
|
+
{
|
83
|
+
body: response.body,
|
84
|
+
headers: response.headers,
|
85
|
+
metadata: construct_metadata(start_time, end_time)
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def construct_metadata(start_time, end_time)
|
91
|
+
total_time = end_time - start_time
|
92
|
+
|
93
|
+
{
|
94
|
+
start_time: start_time,
|
95
|
+
end_time: end_time,
|
96
|
+
total_time: total_time
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_micro_second_time
|
101
|
+
(Time.now.to_f * 1000000).to_i
|
102
|
+
end
|
103
|
+
|
104
|
+
def construct_base_path(path)
|
105
|
+
"#{base_path}/#{path}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/lib/luno/markets.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# These are not official API endpoints for Luno.
|
2
|
+
# Rather this is data taken from the Luno website and parsed into JSON
|
3
|
+
|
4
|
+
module Luno
|
5
|
+
module OtherData
|
6
|
+
def ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/'])
|
7
|
+
endpoint_metrics = paths.map do |path|
|
8
|
+
responses = []
|
9
|
+
|
10
|
+
limit.times do
|
11
|
+
responses << unauthorised_and_send(http_method: :get, path: path)
|
12
|
+
end
|
13
|
+
|
14
|
+
avg_time = responses
|
15
|
+
.map { |r| r.dig(:metadata)&.dig(:total_time) }
|
16
|
+
.reduce(&:+) / limit
|
17
|
+
|
18
|
+
{
|
19
|
+
path: path,
|
20
|
+
average_time: avg_time
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
{
|
25
|
+
metadata: {
|
26
|
+
endpoint_metrics: endpoint_metrics
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def countries
|
32
|
+
call_countries
|
33
|
+
end
|
34
|
+
|
35
|
+
# From API Documentation
|
36
|
+
def currencies
|
37
|
+
lines = []
|
38
|
+
|
39
|
+
call_api_documentation
|
40
|
+
.at('div#tag\/Currency')
|
41
|
+
.search('li')
|
42
|
+
.map(&:text)
|
43
|
+
.map { |text| text.split.join(" ") }
|
44
|
+
end
|
45
|
+
|
46
|
+
def permissions
|
47
|
+
call_api_documentation
|
48
|
+
end
|
49
|
+
|
50
|
+
def changelog
|
51
|
+
lines = []
|
52
|
+
|
53
|
+
call_api_documentation
|
54
|
+
.at('div#tag\/Changelog')
|
55
|
+
.search('li')
|
56
|
+
.map(&:text)
|
57
|
+
.map { |text| text.split.join(" ") }
|
58
|
+
.map { |text|
|
59
|
+
if (text[10] != ':' || unable_to_parse_time(text[0,10])) # ':' is at character 10
|
60
|
+
lines[-1] = "#{lines[-1]}\n#{text}"
|
61
|
+
else
|
62
|
+
lines << text
|
63
|
+
end
|
64
|
+
}
|
65
|
+
|
66
|
+
output = {}
|
67
|
+
|
68
|
+
lines.each do |line|
|
69
|
+
tuple = line.split(':')
|
70
|
+
text = tuple[1, lines.size].join(':')
|
71
|
+
key = tuple[0]
|
72
|
+
|
73
|
+
output.merge!(key => text)
|
74
|
+
end
|
75
|
+
|
76
|
+
output
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def call_countries
|
82
|
+
parse_html(HTTParty.get('https://www.luno.com/en/countries').body)
|
83
|
+
end
|
84
|
+
|
85
|
+
def call_api_documentation
|
86
|
+
parse_html(HTTParty.get('https://www.luno.com/en/developers/api').body)
|
87
|
+
end
|
88
|
+
|
89
|
+
def parse_html(raw_html)
|
90
|
+
Nokogiri::HTML(raw_html)
|
91
|
+
end
|
92
|
+
|
93
|
+
def unable_to_parse_time(str)
|
94
|
+
!parse_time(str)
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_time(str)
|
98
|
+
Time.parse(str)
|
99
|
+
rescue ArgumentError => _e
|
100
|
+
false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/luno/sending.rb
ADDED
data/lib/luno/version.rb
ADDED
data/luno.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "luno/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "luno"
|
7
|
+
spec.version = Luno::VERSION
|
8
|
+
spec.authors = ["trex22"]
|
9
|
+
spec.email = ["contact@jasonchalom.com"]
|
10
|
+
|
11
|
+
spec.summary = "A client for using the Luno API in Ruby."
|
12
|
+
spec.description = "A client for using the Luno API in Ruby. It relies on the swagger spec from their api documentation. https://www.luno.com/en/developers/api"
|
13
|
+
spec.homepage = "https://github.com/TRex22/luno"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "httparty", "~> 0.18"
|
26
|
+
spec.add_dependency "active_attr", "~> 0.15"
|
27
|
+
spec.add_dependency "nokogiri", "~> 1.10.9"
|
28
|
+
|
29
|
+
# Development dependancies
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
spec.add_development_dependency "minitest-focus", "~> 1.1.2"
|
34
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.4.2"
|
35
|
+
spec.add_development_dependency "timecop", "~> 0.9.1"
|
36
|
+
spec.add_development_dependency "mocha", "~> 1.11.2"
|
37
|
+
spec.add_development_dependency "pry", "~> 0.13"
|
38
|
+
spec.add_development_dependency "webmock", "~> 3.8.3"
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: luno
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- trex22
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.18'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.18'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_attr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.15'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.10.9
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.10.9
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.17'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-focus
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.1.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest-reporters
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.4.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.4.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.9.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.9.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: mocha
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.11.2
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.11.2
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.13'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.13'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 3.8.3
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 3.8.3
|
181
|
+
description: A client for using the Luno API in Ruby. It relies on the swagger spec
|
182
|
+
from their api documentation. https://www.luno.com/en/developers/api
|
183
|
+
email:
|
184
|
+
- contact@jasonchalom.com
|
185
|
+
executables: []
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- ".gitignore"
|
190
|
+
- ".ruby-version"
|
191
|
+
- CODE_OF_CONDUCT.md
|
192
|
+
- Gemfile
|
193
|
+
- Gemfile.lock
|
194
|
+
- LICENSE
|
195
|
+
- LICENSE.txt
|
196
|
+
- README.md
|
197
|
+
- Rakefile
|
198
|
+
- bin/console
|
199
|
+
- bin/setup
|
200
|
+
- lib/luno.rb
|
201
|
+
- lib/luno/accounts.rb
|
202
|
+
- lib/luno/beneficiaries.rb
|
203
|
+
- lib/luno/client.rb
|
204
|
+
- lib/luno/lightning.rb
|
205
|
+
- lib/luno/markets.rb
|
206
|
+
- lib/luno/orders.rb
|
207
|
+
- lib/luno/other_data.rb
|
208
|
+
- lib/luno/quotes.rb
|
209
|
+
- lib/luno/receiving.rb
|
210
|
+
- lib/luno/sending.rb
|
211
|
+
- lib/luno/streaming.rb
|
212
|
+
- lib/luno/transactions.rb
|
213
|
+
- lib/luno/version.rb
|
214
|
+
- lib/luno/withdrawals.rb
|
215
|
+
- luno.gemspec
|
216
|
+
homepage: https://github.com/TRex22/luno
|
217
|
+
licenses:
|
218
|
+
- MIT
|
219
|
+
metadata: {}
|
220
|
+
post_install_message:
|
221
|
+
rdoc_options: []
|
222
|
+
require_paths:
|
223
|
+
- lib
|
224
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
+
requirements:
|
231
|
+
- - ">="
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0'
|
234
|
+
requirements: []
|
235
|
+
rubygems_version: 3.0.3
|
236
|
+
signing_key:
|
237
|
+
specification_version: 4
|
238
|
+
summary: A client for using the Luno API in Ruby.
|
239
|
+
test_files: []
|