firefighter 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 65a0d550b0817cc14a79f82f16ba44c628f710cb
4
- data.tar.gz: 1a277e9c5cba8f0df19d4f267ad07b25d917d1a7
2
+ SHA256:
3
+ metadata.gz: a61aa83a2c470f2eda4d65b090c4c2e9b3135e47fa9e7fb8c7cc6634687493f4
4
+ data.tar.gz: afcc14b8df36736a6827f3b83196181f428e5526a1eaee48eea44ad0a27bd769
5
5
  SHA512:
6
- metadata.gz: 74bbdd14e60fc5f6db685fda2413dcde977796667e51fce457176b69e18af4be72f07f79272e1e00784e073b0ca156a10c02f77a2f292f133527bfe59d123934
7
- data.tar.gz: 0e5880b19bf6718f0d6e4ae490bf27dca481bd7f604d97dd527d2839cd2571255b2e84fc8eb83eb9ecc4ea07daf8c603a0a522b2c03747db573c88e74d40b911
6
+ metadata.gz: eaec303e311e8a70f25873345c9e43ad4eac2be9253e88745b2e66c0a9e4177b0185c6b027b94a1f7a560b8d66b648cd18d3960939a283b3171f50e08e9decad
7
+ data.tar.gz: 1c99438eb83576cd16ae696bd018df8505587038300d797d5c238be66a4a30488437cf74151d632483626e15c929716d0b167198de1b99f3f557cf34a81d889e
data/.irbrc ADDED
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path('lib')
2
+
3
+ require 'firefighter'
4
+ require_relative 'spec/support/credentials'
5
+
6
+ @client = Firefighter::RealtimeDatabase.from_env
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- firefighter (0.2.0)
4
+ firefighter (0.2.1)
5
5
  http (~> 3.0)
6
6
  jwt (~> 2.0)
7
7
 
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  webmock (~> 3.4)
68
68
 
69
69
  BUNDLED WITH
70
- 1.16.1
70
+ 1.17.2
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Talk to Firebase API from Ruby:
4
4
 
5
- - signup
6
- - read, write, add data
7
- - generate JWT tokens for token-auth
5
+ - identity: signup, account_info, accounts_download
6
+ - realtime: read, write, add, delete data
7
+ - tokens: generate JWT tokens for token-auth
8
8
 
9
9
  ## Installation
10
10
 
@@ -24,7 +24,49 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- TODO: Write usage instructions here
27
+ ```ruby
28
+ # Firefighter::Identitytoolkit
29
+ # from_env uses environment variables:
30
+ # - FIREBASE_WEB_API_KEY
31
+ # - FIREBASE_SERVICE_ACCOUNT_EMAIL
32
+ identitytoolkit = Firefighter::Identitytoolkit.from_env
33
+
34
+ account = identitytoolkit.signup('test@test.de', 'totalgeheimespasswort')
35
+
36
+ account = identitytoolkit.account_info(account['idToken'])
37
+
38
+ accounts = identitytoolkit.download_accounts
39
+
40
+ token = identitytoolkit.fetch_access_token
41
+
42
+ # Firefighter::RealtimeDatabase
43
+ # from_env uses environment variables:
44
+ # - FIREBASE_WEB_DB_NAME
45
+ # - FIREBASE_WEB_DB_SECRET
46
+ realtime_database = Firefighter::RealtimeDatabase.from_env
47
+
48
+ realtime_database.write("some-path/key", {some: 'data'})
49
+
50
+ hash = realtime_database.read("some-path/key")
51
+
52
+ realtime_database.add("some-path/list", {some: 'data'})
53
+
54
+ list = realtime_database.read("some-path/list")
55
+
56
+ realtime_database.delete("some-path/list")
57
+
58
+ # Firefighter::TokenGenerator
59
+ # from_env uses environment variables:
60
+ # - FIREBASE_SERVICE_ACCOUNT_EMAIL
61
+ # - FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY
62
+ token_generator = Firefighter::TokenGenerator.from_env
63
+
64
+ access_token = token_generator.create_access_token
65
+
66
+ custom_token = token_generator.create_custom_token('someUid', data: {some: 'payload'})
67
+
68
+ payload = token_generator.read_token(custom_token)
69
+ ```
28
70
 
29
71
  ## Development
30
72
 
@@ -39,3 +81,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/phoet/
39
81
  ## Code of Conduct
40
82
 
41
83
  Everyone interacting in the Firefighter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/phoet/firefighter/blob/master/CODE_OF_CONDUCT.md).
84
+
85
+ ## Changelog
86
+
87
+ ### 0.3.0
88
+
89
+ - adds `Firefighter::RealtimeDatabase#delete`
@@ -30,6 +30,11 @@ module Firefighter
30
30
  call(:get, url)
31
31
  end
32
32
 
33
+ def delete(path)
34
+ url = endpoint(path)
35
+ call(:delete, url)
36
+ end
37
+
33
38
  private
34
39
 
35
40
  def endpoint(path)
@@ -1,3 +1,3 @@
1
1
  module Firefighter
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -9,9 +9,12 @@ module Firefighter
9
9
  end
10
10
 
11
11
  def call(method, url, data = {}, headers = {})
12
- if method == :get
12
+ case method
13
+ when :get
13
14
  response = HTTP.get(url, headers: headers)
14
- elsif method == :form
15
+ when :delete
16
+ response = HTTP.delete(url, headers: headers)
17
+ when :form
15
18
  response = HTTP.send(:post, url, form: data, headers: headers)
16
19
  else
17
20
  response = HTTP.send(method, url, json: data, headers: headers)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firefighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-27 00:00:00.000000000 Z
11
+ date: 2019-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".circleci/config.yml"
133
133
  - ".gitignore"
134
+ - ".irbrc"
134
135
  - ".rspec"
135
136
  - CODE_OF_CONDUCT.md
136
137
  - Gemfile
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  version: '0'
167
168
  requirements: []
168
169
  rubyforge_project:
169
- rubygems_version: 2.6.13
170
+ rubygems_version: 2.7.6
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Firebase API Wrapper