Skip to content

Latest commit

 

History

History
72 lines (53 loc) · 2.83 KB

File metadata and controls

72 lines (53 loc) · 2.83 KB

Get Relationships

Wikirate platform can host answers that respond to relationship questions between companies. For instance, which companies supplied company A in 2022? Relationships respond to such questions (metrics with metric type Relation Metric).

This example assumes you have configured your Wikirate REST client. Instructions on how to configure a client can be found in examples/Configurations.md

The get_relationships method supports multiple ways to identify the entity whose relationships you want to retrieve:

  • by metric_name and metric_designer
  • by a generic identifier (numeric ID or card name)

Additional request options are passed via the params hash.

Method signature

get_answers(
  metric_name: nil,
  metric_designer: nil,
  identifier: nil,
  params: {}
)
endpoint params:
  • limit: default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the maximum value will be used.
  • offset: default value 0, the (zero-based) offset of the first item in the collection to return

filter params:

  • year: returns all the relationships reported on the defined year
  • source: returns all relationships that cite the defined source
  • subject_company_id: returns all relationships by subject company id
  • object_company_id: returns all relationships by object company id
  • subject_company_name: returns all relationships by subject company name
  • object_company_name: returns all relationships by object company name
  • value: returns all the relationships with the defined value (e.g. Tier 2 Supplier)
  • name: returns all relationships with the subject company name containing the given string

In the example below, we are looking for Adidas AG suppliers in 2021.

relationships = client.get_relationships('Supplied By',
                                         'Commons',
                                         { 'year' => 2021,
                                           'name' => 'Adidas AG' })
puts relationships

Get Relationships by Metric ID

The get_relationships_by_metric_id functions similarly with the get_relationships method but instead of metric_name and metric_designer gets as an input the metric_id.

Thus, the examples equivalent examples of the previous section using the metric_id will be formulated as follows:

In the example below, we are looking for Adidas AG suppliers in 2021.

relationships = client.get_relationships(2929009,
                                         { 'year' => 2021,
                                           'name' => 'Adidas AG' })
puts relationships