Class: Seekmodo::Sdk::Admin::Client
- Inherits:
-
Object
- Object
- Seekmodo::Sdk::Admin::Client
- Defined in:
- lib/seekmodo/sdk/admin/client.rb
Constant Summary collapse
- DEFAULT_GATEWAY_URL =
"https://mcp.seekmodo.com"
Instance Method Summary collapse
- #add_synonym(tenant_id, body) ⇒ Object
- #analytics_top_queries(tenant_id, window: "7d", limit: 20) ⇒ Object
- #analytics_zero_results(tenant_id, window: "7d", limit: 20) ⇒ Object
- #call(tool, body, tenant_id:) ⇒ Object
-
#initialize(admin_key:, gateway_url: DEFAULT_GATEWAY_URL, connection: nil, user_agent: "Seekmodo-Admin/1.0") ⇒ Client
constructor
A new instance of Client.
- #list_pins(tenant_id) ⇒ Object
- #list_synonyms(tenant_id) ⇒ Object
- #ltr_retrain(tenant_id) ⇒ Object
- #ltr_status(tenant_id, history_limit: nil, history_offset: nil) ⇒ Object
- #remove_synonym(tenant_id, id) ⇒ Object
- #set_pins(tenant_id, body) ⇒ Object
Constructor Details
#initialize(admin_key:, gateway_url: DEFAULT_GATEWAY_URL, connection: nil, user_agent: "Seekmodo-Admin/1.0") ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 22 def initialize(admin_key:, gateway_url: DEFAULT_GATEWAY_URL, connection: nil, user_agent: "Seekmodo-Admin/1.0") @admin_key = admin_key @gateway_url = gateway_url.to_s.delete_suffix("/") @user_agent = user_agent @connection = connection || Faraday.new do |f| f.adapter Faraday.default_adapter end end |
Instance Method Details
#add_synonym(tenant_id, body) ⇒ Object
41 42 43 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 41 def add_synonym(tenant_id, body) call("synonyms.add", body, tenant_id: tenant_id) end |
#analytics_top_queries(tenant_id, window: "7d", limit: 20) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 73 def analytics_top_queries(tenant_id, window: "7d", limit: 20) result = call( "analytics.top_queries", { "window" => window, "limit" => limit }, tenant_id: tenant_id ) result.fetch("rows", []) end |
#analytics_zero_results(tenant_id, window: "7d", limit: 20) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 82 def analytics_zero_results(tenant_id, window: "7d", limit: 20) result = call( "analytics.zero_results", { "window" => window, "limit" => limit }, tenant_id: tenant_id ) result.fetch("rows", []) end |
#call(tool, body, tenant_id:) ⇒ Object
31 32 33 34 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 31 def call(tool, body, tenant_id:) path = tool.start_with?("/") ? tool : "/v1/admin/#{normalize_tool(tool)}" call_rest(path, body.merge("tenant_id" => tenant_id), tenant_id: tenant_id) end |
#list_pins(tenant_id) ⇒ Object
49 50 51 52 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 49 def list_pins(tenant_id) result = call("pins.list", {}, tenant_id: tenant_id) result.fetch("pins", []) end |
#list_synonyms(tenant_id) ⇒ Object
36 37 38 39 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 36 def list_synonyms(tenant_id) result = call("synonyms.list", {}, tenant_id: tenant_id) result.fetch("synonyms", []) end |
#ltr_retrain(tenant_id) ⇒ Object
69 70 71 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 69 def ltr_retrain(tenant_id) call("ltr.retrain", {}, tenant_id: tenant_id) end |
#ltr_status(tenant_id, history_limit: nil, history_offset: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 58 def ltr_status(tenant_id, history_limit: nil, history_offset: nil) params = {} if history_limit params["history_limit"] = [[history_limit, 1].max, 50].min end if history_offset params["history_offset"] = [[history_offset, 0].max, 10_000].min end call("ltr.status", params, tenant_id: tenant_id) end |
#remove_synonym(tenant_id, id) ⇒ Object
45 46 47 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 45 def remove_synonym(tenant_id, id) call("synonyms.remove", { "id" => id }, tenant_id: tenant_id) end |
#set_pins(tenant_id, body) ⇒ Object
54 55 56 |
# File 'lib/seekmodo/sdk/admin/client.rb', line 54 def set_pins(tenant_id, body) call("pins.set", body, tenant_id: tenant_id) end |