Class: Cb::Clients::SavedSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/saved_search.rb

Instance Method Summary collapse

Instance Method Details

#create(saved_search) ⇒ Object



5
6
7
8
9
# File 'lib/cb/clients/saved_search.rb', line 5

def create(saved_search)
  body = saved_search.create_to_xml
  json = cb_client.cb_post(Cb.configuration.uri_saved_search_create, body: body)
  singular_model_response(json, saved_search.external_user_id)
end

#delete(hash) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cb/clients/saved_search.rb', line 17

def delete(hash)
  uri = replace_uri_field(Cb.configuration.uri_saved_search_delete, ':did', hash[:did])
  json = cb_client.cb_delete(
    uri,
    {
      headers: { 'HostSite' => hash[:host_site] },
      query: { "UserOAuthToken" =>hash[:user_oauth_token] }
    }
  )
  Responses::SavedSearch::Delete.new(json)
end

#list(oauth_token, hostsite) ⇒ Object



36
37
38
39
40
# File 'lib/cb/clients/saved_search.rb', line 36

def list(oauth_token, hostsite)
  query = list_query(oauth_token, hostsite)
  json = cb_client.cb_get(Cb.configuration.uri_saved_search_list, query: query)
  Responses::SavedSearch::List.new(json)
end

#retrieve(oauth_token, external_id) ⇒ Object



29
30
31
32
33
34
# File 'lib/cb/clients/saved_search.rb', line 29

def retrieve(oauth_token, external_id)
  query = retrieve_query(oauth_token)
  uri = replace_uri_field(Cb.configuration.uri_saved_search_retrieve, ':did', external_id)
  json = cb_client.cb_get(uri, query: query)
  Responses::SavedSearch::Retrieve.new(json)
end

#update(saved_search) ⇒ Object



11
12
13
14
15
# File 'lib/cb/clients/saved_search.rb', line 11

def update(saved_search)
  body = saved_search.update_to_json
  json = cb_client.cb_put(Cb.configuration.uri_saved_search_update, body: body, headers: headers)
  Responses::SavedSearch::Update.new(json)
end