free_currency-API 0.1.1

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
+ SHA256:
3
+ metadata.gz: d3d8f30522a187c2e46cff20b69ece8b1682ac5603b0aa3b3e49cf6a6227cd58
4
+ data.tar.gz: 7af4ce142bb209915fc5b1aa93ebfe6f7e1f566e9c47ce40e34cba8486b7e20f
5
+ SHA512:
6
+ metadata.gz: '092efa9c1ff84c7c6191aa097076f8e66afbb28326db66969a63354d648bd05cb1592e8ad44053f1647df1d442c3c62a2e4bc190378da10e8f18be9205ecbeea'
7
+ data.tar.gz: bb2ee6645332c2d28a7a28fbeddb2c79d55eaea73876af515463913435cca6614bf4391200b7ddf32fc872d43f89488e483432c498c951df35b5aa8c7ca7fb07
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in free_currency-API.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ free_currency-API (0.1.0)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.5.0)
11
+ faraday (2.7.4)
12
+ faraday-net_http (>= 2.0, < 3.1)
13
+ ruby2_keywords (>= 0.0.4)
14
+ faraday-net_http (3.0.2)
15
+ rake (13.0.6)
16
+ rspec (3.12.0)
17
+ rspec-core (~> 3.12.0)
18
+ rspec-expectations (~> 3.12.0)
19
+ rspec-mocks (~> 3.12.0)
20
+ rspec-core (3.12.1)
21
+ rspec-support (~> 3.12.0)
22
+ rspec-expectations (3.12.2)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-mocks (3.12.5)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-support (3.12.0)
29
+ ruby2_keywords (0.0.5)
30
+
31
+ PLATFORMS
32
+ arm64-darwin-22
33
+
34
+ DEPENDENCIES
35
+ free_currency-API!
36
+ rake (~> 13.0)
37
+ rspec
38
+
39
+ BUNDLED WITH
40
+ 2.2.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # FreeCurrency::API
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/free_currency/API`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'free_currency-API'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install free_currency-API
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/free_currency-API.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "free_currency-API"
5
+ spec.version = "0.1.1"
6
+ spec.authors = ["João Oliveira"]
7
+ spec.email = ["joao.oliveira@hole19golf.com"]
8
+
9
+ spec.summary = "The freecurrencyAPI ruby API :D"
10
+ spec.description = "Provides easier interaction with the freecurrencyAPI REST API"
11
+ #spec.homepage = "TODO: Put your gem's website or public repo URL here."
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
15
+
16
+ #spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/JonhyOliveira/freecurrencyAPI-gem.git"
18
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ #spec.bindir = "exe"
26
+ #spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Dependencies
30
+
31
+ spec.add_development_dependency "rspec"
32
+
33
+ # Use faraday to interact with freecurrency REST API
34
+ spec.add_dependency "faraday"
35
+
36
+ # For more information and examples about making a new gem, checkout our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+
4
+ module FreeCurrencyAPI
5
+
6
+ class API
7
+ def initialize api_key
8
+ @conn = Faraday.new "https://api.freecurrencyapi.com/v1/" do |c|
9
+ c.response :json
10
+ c.adapter :net_http
11
+ c.headers = {apikey: "#{api_key}"}
12
+ end
13
+ end
14
+
15
+ def latest_exchange_rates
16
+ do_request "latest"
17
+ end
18
+
19
+ def available_currencies
20
+ do_request "currencies"
21
+ end
22
+
23
+ private
24
+ #
25
+ # Makes a request to an endpoint and returns the result
26
+ #
27
+ # @param [String] endpoint the string describing the endpoint
28
+ #
29
+ # @return [Hash|String] the result of the request, if successfull will return an hash
30
+ # describing the returned data, otherwise returns a message specifying what went wrong
31
+ #
32
+ def do_request endpoint
33
+ resp = @conn.get endpoint
34
+
35
+ if resp.success?
36
+ return resp.body["data"]
37
+ else
38
+ return resp.body["message"]
39
+ end
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: free_currency-API
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - João Oliveira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: faraday
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: Provides easier interaction with the freecurrencyAPI REST API
42
+ email:
43
+ - joao.oliveira@hole19golf.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - free_currency-API.gemspec
54
+ - lib/freecurrencyAPI/API.rb
55
+ homepage:
56
+ licenses: []
57
+ metadata:
58
+ allowed_push_host: https://rubygems.org
59
+ source_code_uri: https://github.com/JonhyOliveira/freecurrencyAPI-gem.git
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.3.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.2.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: The freecurrencyAPI ruby API :D
79
+ test_files: []