Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
crystal_sdk (1.1.1)
crystal_sdk (1.2.1)
nestful (~> 1.1)
recursive-open-struct (~> 1.0)

Expand All @@ -14,9 +14,9 @@ GEM
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
hashdiff (0.3.2)
nestful (1.1.1)
nestful (1.1.3)
public_suffix (2.0.5)
recursive-open-struct (1.0.4)
recursive-open-struct (1.1.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
Expand Down Expand Up @@ -45,4 +45,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.13.6
1.16.1
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ end
end
```


### Relationships
```ruby
profile1 = CrystalSDK::Profile.search({})
profile2 = CrystalSDK::Profile.search({})
CrystalSDK::Api.make_request(:post, "relationships/#{profile1.request_id}/#{profile2.request_id}")
```

## Asynchronous Flow (For bulk analysis)

When requesting large amounts of profiles, or when wanting to have more fine-grained control over performance, we recommend using our asynchronous flow. It allows us to process your requests in parallel and get the information back to you more quickly. There are a couple options for using this capability.
Expand Down
7 changes: 4 additions & 3 deletions lib/crystal_sdk/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@

module CrystalSDK
class Profile
attr_reader :info, :recommendations
attr_reader :info, :recommendations, :request_id

def initialize(info, recommendations)
def initialize(info:, recommendations:, request_id:)
@info = info
@recommendations = recommendations
@request_id = request_id
end

class << self
def from_request(req)
return nil unless req.did_find_profile?

profile_info = req.profile_info
Profile.new(profile_info[:info], profile_info[:recommendations])
Profile.new(info: profile_info[:info], recommendations: profile_info[:recommendations], request_id: req.id)
end

def search(query, timeout: 30)
Expand Down
1 change: 1 addition & 0 deletions spec/crystal_sdk/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

it 'should use the correct request' do
resp = double(
id: 'deadbeef',
did_finish?: true,
did_find_profile?: true,
profile_info: { info: 'info', recommendations: 'recs' }
Expand Down