familysearch2 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -4
- data/lib/familysearch2.rb +3 -3
- data/lib/familysearch2/version.rb +1 -1
- data/test.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f206817f6cc5477a46fb5e3b8363ae693b773ea
|
4
|
+
data.tar.gz: d3d9813e691035210a469f7e4901f78624760d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8b7e022325f5aac1d48091613f6a5f22b1e1afb507d48b4ce5aff7736540b7e7f78862d6f2aec75734fc6dfc10a9cf9544e8a002ec7362769958e0ad67a3e85
|
7
|
+
data.tar.gz: 90fdd562514dda6a2f0df012271a155926a0f95d8f199b9ac9bc9c6a1347e4ed086d70eb6d50a29193bebb57309ea2fe0324d75a37c7f42c6fb62f1080f55e48
|
data/README.md
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# Familysearch2
|
2
2
|
|
3
|
-
|
3
|
+
A gem used to work with the familysearch api.
|
4
|
+
|
5
|
+
The original familysearch gem, https://github.com/jimmyz/familysearch-rb, is currently not working so as an attempt to make my first ruby gem, I decided to take a stab at making my own version. It is based on the gem.
|
4
6
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
10
11
|
|
11
12
|
```ruby
|
12
|
-
gem '
|
13
|
+
gem 'familysearch2'
|
13
14
|
```
|
14
15
|
|
15
16
|
And then execute:
|
@@ -22,7 +23,21 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
```ruby
|
27
|
+
# create a new client
|
28
|
+
# environment options: "production","staging","sandbox"
|
29
|
+
@client = Familyseach2::Client.new(username: "", password: "", environment: "")
|
30
|
+
|
31
|
+
# updating the library will create a file that contains the basic api endpoints
|
32
|
+
@client.update_library
|
33
|
+
|
34
|
+
# create an agent to run your requests
|
35
|
+
agent = @client.get_agent
|
36
|
+
|
37
|
+
# GET syntax
|
38
|
+
response = agent.get '/platform/users/current' param: "value"
|
39
|
+
puts response
|
40
|
+
```
|
26
41
|
|
27
42
|
## Development
|
28
43
|
|
data/lib/familysearch2.rb
CHANGED
@@ -15,7 +15,7 @@ module Familyseach2
|
|
15
15
|
faraday.headers['Accept'] = 'application/x-fs-v1+json,application/x-gedcomx-atom+json,application/json'
|
16
16
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
17
17
|
end
|
18
|
-
get_access_token(params[:username],params[:password],params[:environment])
|
18
|
+
get_access_token(params[:username],params[:password],params[:environment],@key )
|
19
19
|
@agent
|
20
20
|
end
|
21
21
|
|
@@ -31,10 +31,10 @@ module Familyseach2
|
|
31
31
|
base_url
|
32
32
|
end
|
33
33
|
|
34
|
-
def get_access_token(username,password,env)
|
34
|
+
def get_access_token(username,password,env,key)
|
35
35
|
meta
|
36
36
|
url = JSON.parse(@discovery)['links']['fs-identity-v2-login']['href']
|
37
|
-
@client_id =
|
37
|
+
@client_id = key
|
38
38
|
RestClient::Resource.new url, username, password
|
39
39
|
|
40
40
|
request_url = get_base_url(env) + "/identity/v2/request_token"
|
data/test.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require 'rest-client'
|
2
|
-
require 'oauth'
|
3
2
|
|
4
3
|
require File.expand_path(File.dirname(__FILE__) + '/lib/familysearch2')
|
5
4
|
|
6
|
-
|
5
|
+
# create a new client
|
6
|
+
# environment options: "production","staging","sandbox"
|
7
|
+
@client = Familyseach2::Client.new(username: "", password: "", environment: "")
|
8
|
+
|
9
|
+
# updating the library will create a file that contains the basic api endpoints
|
7
10
|
@client.update_library
|
8
11
|
|
12
|
+
# create an agent to run your requests
|
9
13
|
agent = @client.get_agent
|
10
14
|
|
15
|
+
# GET syntax
|
11
16
|
response = agent.get '/platform/users/current'
|
12
|
-
puts response
|
13
|
-
# RestClient.get "https://sandbox.familysearch.org/platform/users/current", {:Authorization => "Bearer #{@access_token}"}
|
14
|
-
|
15
|
-
|
17
|
+
puts response
|
16
18
|
|
17
19
|
|