keybase-unofficial-api 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: 64e949400e24f64b7d16f3f299752f198b3f5661
4
+ data.tar.gz: e03734a324ab0e4a9ed67378456317db735bb501
5
+ SHA512:
6
+ metadata.gz: 7bdfa548bad2a519d06117aa61151d40c9e945cd2c0ce9d794534e256da099bf9930a6110f643ec32ed2c78db149d5721546c5b3172ea03492c69427325fa89e
7
+ data.tar.gz: 366fc167ccf3eb59f8563eba1d779e0a1fab74f2d58f016950e3645ef4009808da4683b72115415bbe5ba4a740be3322c2ad242000774aaafd124f3165c35937
@@ -0,0 +1 @@
1
+ --no-private --markup-provider=redcarpet --markup=markdown - *.md LICENSE
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 William Woodruff <william @ yossarian.net>
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.
@@ -0,0 +1,15 @@
1
+ keybase-unofficial-api
2
+ ======================
3
+
4
+ An unofficial Ruby library for the Keybase REST API.
5
+
6
+ ### Installation
7
+
8
+ ```bash
9
+ gem install keybase-unofficial-api
10
+ ```
11
+
12
+ ### Documentation
13
+
14
+ Documentation for the current release can be found on
15
+ [RubyDoc](http://www.rubydoc.info/gems/keybase-unofficial-api/).
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "keybase/core"
4
+
5
+ require_relative "api/api"
6
+
7
+ # The primary namespace.
8
+ module Keybase
9
+ module API
10
+ # The current version of `keybase-unofficial-api`.
11
+ VERSION = "0.0.1"
12
+ end
13
+ end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "json"
5
+ require "ostruct"
6
+
7
+ module Keybase
8
+ # Represents (parts of) the Keybase REST API.
9
+ # @see https://keybase.io/docs/api/1.0
10
+ module API
11
+ # The base URL for the majority of API calls.
12
+ BASE_URL = "https://keybase.io/_/api/1.0"
13
+
14
+ class << self
15
+ # Look up a user, users, or external identity.
16
+ # @param query [Hash] the request parameters
17
+ # @option query username [String] the username to look up
18
+ # @option query usernames [Array<String>] multiple usernames to look up
19
+ # @return [OpenStruct] a struct mapping of the JSON response
20
+ # @example
21
+ # Keybase::API.lookup username: "yossarian"
22
+ # Keybase::API.lookup github: "woodruffw"
23
+ # @note Any identity supported by keybase should work (e.g, `domain`,
24
+ # `hackernews`, `reddit`, `github`, etc.)
25
+ # @see https://keybase.io/docs/api/1.0/call/user/lookup
26
+ def lookup(**query)
27
+ query[:usernames] = Core::U[query[:usernames]]
28
+
29
+ fetch_and_structify "/user/lookup.json", query
30
+ end
31
+
32
+ # Test whether the given user exists on Keybase.
33
+ # @param user [String] the username to test
34
+ # @return [Boolean] whether or not the user exists
35
+ # @example
36
+ # Keybase::API.user? "yossarian" # => true
37
+ # Keybase::API.user? "idonotexist" # => false
38
+ # @note This call only works on Keybase usernames, not external identities.
39
+ def user?(user)
40
+ lookup(username: user).status.code.zero?
41
+ end
42
+
43
+ # Search Keybase for identity components.
44
+ # @param query [String] the string to search for
45
+ # @return [OpenStruct] a struct mapping of the JSON response
46
+ # @example
47
+ # Keybase::API.autocomplete "William Woodruff"
48
+ # @see https://keybase.io/docs/api/1.0/call/user/autocomplete
49
+ def autocomplete(query)
50
+ fetch_and_structify "/user/autocomplete.json", q: query
51
+ end
52
+
53
+ # Discover Keybase users from external identities.
54
+ # @param query [Hash] the request parameters
55
+ # @option query flatten [Boolean] whether or not to remove duplicates
56
+ # @option query usernames_only [Boolean] whether or not to reply with
57
+ # only names
58
+ # @return [OpenStruct] a struct mapping of the JSON response
59
+ # @example
60
+ # Keybase::API.discover github: "woodruffw", flatten: true
61
+ # @note Any identity supported by keybase should work (e.g, `domain`,
62
+ # `hackernews`, `reddit`, `github`, etc.)
63
+ # @see https://keybase.io/docs/api/1.0/call/user/discover
64
+ def discover(**query)
65
+ fetch_and_structify "/user/discover.json", query
66
+ end
67
+
68
+ # Retrieve the current site-wide Merkle root hash.
69
+ # @param query [Hash] the request parameters
70
+ # @option query seqno [Integer] a specific Merkle root to return, if found
71
+ # @option query ctime [Integer] return the first root on or after the
72
+ # given time (UTC)
73
+ # @return [OpenStruct] a struct mapping of the JSON response
74
+ # @see https://keybase.io/docs/api/1.0/call/merkle/root
75
+ def merkle_root(**query)
76
+ fetch_and_structify "/merkle/root.json", query
77
+ end
78
+
79
+ # Retrieve a Merkle node corresponding to a given hash.
80
+ # @param query [Hash] the request parameters
81
+ # @option query hash [String] the hash of the block to look up
82
+ # @return [OpenStruct] a struct mapping of the JSON response
83
+ # @see https://keybase.io/docs/api/1.0/call/merkle/block
84
+ def merkle_block(**query)
85
+ fetch_and_structify "/merkle/block.json", query
86
+ end
87
+
88
+ # Make a GET request to the given endpoint with the given parameters.
89
+ # @param endpoint [String] the keybase API endpoint
90
+ # @param query [Hash] the request parameters
91
+ # @return [OpenStruct] a struct mapping of the JSON response
92
+ # @api private
93
+ def fetch_and_structify(endpoint, query)
94
+ response = Faraday.get "#{BASE_URL}#{endpoint}", query
95
+ JSON.parse(response.body, object_class: OpenStruct)
96
+ end
97
+ end
98
+ end
99
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: keybase-unofficial-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - William Woodruff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: keybase-unofficial-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: 'This library provides access to Keybase''s REST API from Ruby.
42
+
43
+ '
44
+ email: william@tuffbizz.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".yardopts"
50
+ - LICENSE
51
+ - README.md
52
+ - lib/keybase/api.rb
53
+ - lib/keybase/api/api.rb
54
+ homepage: https://github.com/woodruffw/keybase-unofficial-api
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.3.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.6.13
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: keybase-unofficial-api - Unofficial library for the Keybase API
78
+ test_files: []