wikirate4ruby 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -0
- data/Gemfile.lock +81 -0
- data/LICENSE +673 -673
- data/README.md +45 -1
- data/examples/Add Answer.md +41 -0
- data/examples/Add Company.md +39 -0
- data/examples/Add Relationship.md +43 -0
- data/examples/Add Source.md +65 -0
- data/examples/Configuration.md +35 -0
- data/examples/Get Answer.md +24 -0
- data/examples/Get Answers.md +137 -0
- data/examples/Get Companies.md +52 -0
- data/examples/Get Company Group.md +27 -0
- data/examples/Get Company Groups.md +35 -0
- data/examples/Get Company.md +20 -0
- data/examples/Get Dataset.md +25 -0
- data/examples/Get Datasets.md +33 -0
- data/examples/Get Metric.md +32 -0
- data/examples/Get Metrics.md +72 -0
- data/examples/Get Project.md +21 -0
- data/examples/Get Projects.md +36 -0
- data/examples/Get Relationship.md +27 -0
- data/examples/Get Relationships.md +72 -0
- data/examples/Get Research Group.md +19 -0
- data/examples/Get Research Groups.md +30 -0
- data/examples/Get Source.md +22 -0
- data/examples/Get Sources.md +68 -0
- data/examples/Get Topic.md +19 -0
- data/examples/Get Topics.md +47 -0
- data/examples/README.md +36 -0
- data/examples/Update Answer.md +47 -0
- data/examples/Update Company.md +42 -0
- data/examples/Update Relationship.md +43 -0
- data/examples/Update Source.md +61 -0
- data/lib/wikirate4ruby/client.rb +393 -394
- data/lib/wikirate4ruby/entities/answer.rb +37 -26
- data/lib/wikirate4ruby/entities/card.rb +82 -81
- data/lib/wikirate4ruby/entities/checked_by.rb +19 -19
- data/lib/wikirate4ruby/entities/company.rb +28 -25
- data/lib/wikirate4ruby/entities/company_group.rb +20 -20
- data/lib/wikirate4ruby/entities/dataset.rb +20 -20
- data/lib/wikirate4ruby/entities/metric.rb +43 -43
- data/lib/wikirate4ruby/entities/region.rb +20 -20
- data/lib/wikirate4ruby/entities/{relationship_answer.rb → relationship.rb} +23 -23
- data/lib/wikirate4ruby/entities/research_group.rb +18 -18
- data/lib/wikirate4ruby/entities/source.rb +43 -27
- data/lib/wikirate4ruby/entities/topic.rb +24 -20
- data/lib/wikirate4ruby/error.rb +98 -98
- data/lib/wikirate4ruby/request.rb +99 -99
- data/lib/wikirate4ruby/request_utils.rb +36 -36
- data/lib/wikirate4ruby/utils.rb +29 -16
- data/lib/wikirate4ruby/version.rb +1 -1
- data/lib/wikirate4ruby.rb +1 -1
- data/wikirate4ruby.gemspec +39 -0
- metadata +36 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## Get Metric
|
|
2
|
+
|
|
3
|
+
_A Metric is a tool for measuring. On WikiRate, metrics are used to measure company performance, and they are a way of
|
|
4
|
+
asking the same question of many companies. It consists of a question, an About section (which describes why this metric
|
|
5
|
+
is important and how it is used), and a Methodology section (which describes how to research the answer)._
|
|
6
|
+
|
|
7
|
+
_Some metric answers are researched, and their values and source citations are entered directly. Other answers are
|
|
8
|
+
dynamically calculated from other answers. [Learn More](https://wikirate.org/About_Metrics)_
|
|
9
|
+
|
|
10
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
11
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
12
|
+
|
|
13
|
+
The `get_metric` method take as an input either the metric name or the metric's identifier.
|
|
14
|
+
|
|
15
|
+
Each metric's name is composed by it's designer+title (eg. Core+Company Report Available).
|
|
16
|
+
```ruby
|
|
17
|
+
# get a metric by name, returns a Metric object
|
|
18
|
+
metric = client.get_metric("Core+Company_Report_Available")
|
|
19
|
+
puts metric.question
|
|
20
|
+
puts metric.about
|
|
21
|
+
puts metric.methodology
|
|
22
|
+
# prints the metric type
|
|
23
|
+
puts metric.metric_type
|
|
24
|
+
# print the formula applied for the calculations if the metric is a Formula metric
|
|
25
|
+
puts metric.formula
|
|
26
|
+
# prints the metric as a json
|
|
27
|
+
puts metric.to_json
|
|
28
|
+
# prints the raw json response
|
|
29
|
+
puts metric.raw_json
|
|
30
|
+
# get a metric by id, returns a Metric object
|
|
31
|
+
metric = client.get_metric(7217)
|
|
32
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## Get Metrics
|
|
2
|
+
|
|
3
|
+
_A Metric is a tool for measuring. On WikiRate, metrics are used to measure company performance, and they are a way of
|
|
4
|
+
asking the same question of many companies. It consists of a question, an About section (which describes why this metric
|
|
5
|
+
is important and how it is used), and a Methodology section (which describes how to research the answer)._
|
|
6
|
+
|
|
7
|
+
_Some metric answers are researched, and their values and source citations are entered directly. Other answers are
|
|
8
|
+
dynamically calculated from other answers. [Learn More](https://wikirate.org/About_Metrics)_
|
|
9
|
+
|
|
10
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
11
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
12
|
+
|
|
13
|
+
The `get_metrics` method take as an input a `Hash` where the user can define the parameters of their request. More
|
|
14
|
+
specifically, we could divide our params in two different types of parameters, the endpoint parameters and the filter
|
|
15
|
+
parameters. The endpoint parameters help us to iterate through our query's results and the filter parameters allow us to
|
|
16
|
+
restrict our results based on specific given input.
|
|
17
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
18
|
+
endpoint params:
|
|
19
|
+
|
|
20
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
21
|
+
maximum value will be used.
|
|
22
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
23
|
+
|
|
24
|
+
filter params:
|
|
25
|
+
|
|
26
|
+
- **_name:_**: returns all metrics that contain in their name the given string.
|
|
27
|
+
- **_bookmark_**: returns the metrics you have bookmarked, allowed parameter values:
|
|
28
|
+
|
|
29
|
+
- 'bookmark'
|
|
30
|
+
- 'nobookmark'
|
|
31
|
+
- **_wikirate_topic_**: returns all metrics that fall under the defined wikirate topic. All wikirate topics can be
|
|
32
|
+
found [here](https://wikirate.org/Topic).
|
|
33
|
+
- **_designer_**: returns all metrics the given designer created.
|
|
34
|
+
- **_published_**: returns all metrics based on status published or not published. Note that only stewards are allowed
|
|
35
|
+
to filter based on status. Allowed parameter values:
|
|
36
|
+
|
|
37
|
+
- 'true': for published metrics (default)
|
|
38
|
+
- 'false': for not published metrics
|
|
39
|
+
- 'all': for published and unpublished
|
|
40
|
+
- **_metric_type_**: returns all metrics of the given metric type. If you want to learn more about the different
|
|
41
|
+
wikirate metric types follow this [link](https://wikirate.org/About_Metrics). Allowed parameter values:
|
|
42
|
+
|
|
43
|
+
- 'researched'
|
|
44
|
+
- 'relationship'
|
|
45
|
+
- 'inverse relationship'
|
|
46
|
+
- 'formula'
|
|
47
|
+
- 'wikirating'
|
|
48
|
+
- 'score'
|
|
49
|
+
- 'descendant'
|
|
50
|
+
- **_value_type_**: returns all metric that their answers are of the specified value type. Allowed parameter values:
|
|
51
|
+
|
|
52
|
+
- 'number'
|
|
53
|
+
- 'money'
|
|
54
|
+
- 'category'
|
|
55
|
+
- 'multi-category'
|
|
56
|
+
- 'free text'
|
|
57
|
+
- **_research_policy_**: returns all metrics that follow the given research policy. Allowed parameter values:
|
|
58
|
+
|
|
59
|
+
- 'community assessed'
|
|
60
|
+
- 'designer assessed'
|
|
61
|
+
- **_dataset_**: returns all metrics contained on the given dataset. All available wikirate datasets can be
|
|
62
|
+
found [here](https://wikirate.org/Data%20Set).
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
In the example below, we are asking to get 50 community assessed metrics which are designed by Walk Free
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
metrics = client.get_metrics({ 'limit' => 50,
|
|
70
|
+
'research_policy' => 'community assessed',
|
|
71
|
+
'designer' => 'Walk Free' })
|
|
72
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Get Project
|
|
2
|
+
|
|
3
|
+
_Projects are tools to organize, gather and analyse data on companies' environmental, social and governance performance.
|
|
4
|
+
Through Projects you can pull together a specific set of companies (by topic or sector, for example) and metrics to help
|
|
5
|
+
you and other WikiRate researchers contribute data that illuminates sustainability performance._
|
|
6
|
+
|
|
7
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
8
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
9
|
+
|
|
10
|
+
The `get_project` method take as an input either the project name or the project's identifier.
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
# get a project by name, returns a Card object
|
|
14
|
+
project = client.get_project("Research: Business Contributions to the SDGs (PRME Research)")
|
|
15
|
+
# prints the company as a json
|
|
16
|
+
puts project.to_json
|
|
17
|
+
# prints the raw json response
|
|
18
|
+
puts project.raw_json
|
|
19
|
+
# get a company by id, returns a Company object
|
|
20
|
+
project = client.get_company(7927459)
|
|
21
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## Get Projects
|
|
2
|
+
|
|
3
|
+
_Projects are tools to organize, gather and analyse data on companies' environmental, social and governance performance.
|
|
4
|
+
Through Projects you can pull together a specific set of companies (by topic or sector, for example) and metrics to help
|
|
5
|
+
you and other WikiRate researchers contribute data that illuminates sustainability performance._
|
|
6
|
+
|
|
7
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
8
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
9
|
+
|
|
10
|
+
The `get_projects` method take as an input a `Hash` where the user can define the parameters of their request. More
|
|
11
|
+
specifically, we could divide our params in two different types of parameters, the endpoint parameters and the filter
|
|
12
|
+
parameters. The endpoint parameters help us to iterate through our query's results and the filter parameters allow us to
|
|
13
|
+
restrict our results based on specific given input.
|
|
14
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
15
|
+
endpoint params:
|
|
16
|
+
|
|
17
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
18
|
+
maximum value will be used.
|
|
19
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
20
|
+
|
|
21
|
+
filter params:
|
|
22
|
+
|
|
23
|
+
- **_name:_** returns projects that contain in their name the given string
|
|
24
|
+
- **_wikirate_status_**: returns projects of the given status. Allow parameter values:
|
|
25
|
+
|
|
26
|
+
- 'active'
|
|
27
|
+
- 'inactive'
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
In the example below, we are looking for all the currently active projects.
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
projects = client.get_projects({ 'wikirate_status' => 'active' })
|
|
35
|
+
puts projects
|
|
36
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Get Relationship
|
|
2
|
+
|
|
3
|
+
_Wikirate platform can host answers that respond to relationship questions between companies. For instance, which
|
|
4
|
+
companies supplied company A in 2022? Relationship answers respond to such questions (metrics with metric type
|
|
5
|
+
Relation Metric)._
|
|
6
|
+
|
|
7
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
8
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
9
|
+
|
|
10
|
+
The `get_relationship` method take as an input either the relationship answer's name or the relationship answer's
|
|
11
|
+
identifier.
|
|
12
|
+
|
|
13
|
+
Each relationship's name is described by the metric name (metric designer + metric title), subject company, year
|
|
14
|
+
and object company.
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
# get a relationship answer by name, returns a Relationship object
|
|
18
|
+
answer = client.get_relationship("Commons+Tea Supplied By+Unilever+2021+Beitia Tea")
|
|
19
|
+
# prints the relationship answer's value
|
|
20
|
+
puts answer.value
|
|
21
|
+
# prints the answer as a json
|
|
22
|
+
puts answer.to_json
|
|
23
|
+
# prints the raw json response
|
|
24
|
+
puts answer.raw_json
|
|
25
|
+
# get a relationship answer by id, returns an RelationshipAnswer object
|
|
26
|
+
answer = client.get_relationship(8144117)
|
|
27
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## Get Relationships
|
|
2
|
+
|
|
3
|
+
_Wikirate platform can host answers that respond to relationship questions between companies. For instance, which
|
|
4
|
+
companies supplied company A in 2022? Relationships respond to such questions (metrics with metric type
|
|
5
|
+
Relation Metric)._
|
|
6
|
+
|
|
7
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
8
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
9
|
+
|
|
10
|
+
The `get_relationships` method supports **multiple ways to identify the entity** whose relationships you want to retrieve:
|
|
11
|
+
|
|
12
|
+
- by `metric_name` **and** `metric_designer`
|
|
13
|
+
- by a generic `identifier` (numeric ID or card name)
|
|
14
|
+
|
|
15
|
+
Additional request options are passed via the `params` hash.
|
|
16
|
+
|
|
17
|
+
### Method signature
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
get_answers(
|
|
21
|
+
metric_name: nil,
|
|
22
|
+
metric_designer: nil,
|
|
23
|
+
identifier: nil,
|
|
24
|
+
params: {}
|
|
25
|
+
)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
29
|
+
endpoint params:
|
|
30
|
+
|
|
31
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
32
|
+
maximum value will be used.
|
|
33
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
34
|
+
|
|
35
|
+
filter params:
|
|
36
|
+
|
|
37
|
+
- **_year_**: returns all the relationships reported on the defined year
|
|
38
|
+
- **_source_**: returns all relationships that cite the defined source
|
|
39
|
+
- **_subject_company_id_**: returns all relationships by subject company id
|
|
40
|
+
- **_object_company_id_**: returns all relationships by object company id
|
|
41
|
+
- **_subject_company_name_**: returns all relationships by subject company name
|
|
42
|
+
- **_object_company_name_**: returns all relationships by object company name
|
|
43
|
+
- **_value_**: returns all the relationships with the defined value (e.g. Tier 2 Supplier)
|
|
44
|
+
- **_name:_** returns all relationships with the subject company name containing the given string
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
In the example below, we are looking for Adidas AG suppliers in 2021.
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
relationships = client.get_relationships('Supplied By',
|
|
52
|
+
'Commons',
|
|
53
|
+
{ 'year' => 2021,
|
|
54
|
+
'name' => 'Adidas AG' })
|
|
55
|
+
puts relationships
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Get Relationships by Metric ID
|
|
59
|
+
|
|
60
|
+
The `get_relationships_by_metric_id` functions similarly with the `get_relationships` method but instead
|
|
61
|
+
of `metric_name` and `metric_designer` gets as an input the `metric_id`.
|
|
62
|
+
|
|
63
|
+
Thus, the examples equivalent examples of the previous section using the metric_id will be formulated as follows:
|
|
64
|
+
|
|
65
|
+
In the example below, we are looking for Adidas AG suppliers in 2021.
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
relationships = client.get_relationships(2929009,
|
|
69
|
+
{ 'year' => 2021,
|
|
70
|
+
'name' => 'Adidas AG' })
|
|
71
|
+
puts relationships
|
|
72
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Get Research Group
|
|
2
|
+
|
|
3
|
+
_Research Groups are a collection of WikiRate contributors, their Research Projects, and Metrics they created._
|
|
4
|
+
|
|
5
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
6
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
7
|
+
|
|
8
|
+
The `get_research_group` method take as an input either the research group's name or the research group's identifier.
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
# get a research group by name, returns a ResearchGroup object
|
|
12
|
+
research_group = client.get_research_group("University of Nottingham - Modern Slavery Research Group 2020")
|
|
13
|
+
# prints the research group as a json
|
|
14
|
+
puts research_group.to_json
|
|
15
|
+
# prints the raw json response
|
|
16
|
+
puts research_group.raw_json
|
|
17
|
+
# get a research group by id, returns a ResearchGroup object
|
|
18
|
+
research_group = client.get_research_group(2301582)
|
|
19
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
## Get Research Groups
|
|
2
|
+
|
|
3
|
+
_Research Groups are a collection of WikiRate contributors, their Research Projects, and Metrics they created._
|
|
4
|
+
|
|
5
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
6
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
7
|
+
|
|
8
|
+
The `get_research_groups` method take as an input a `Hash` where the user can define the parameters of their request.
|
|
9
|
+
More specifically, we could divide our params in two different types of parameters, the endpoint parameters and the
|
|
10
|
+
filter parameters. The endpoint parameters help us to iterate through our query's results and the filter parameters
|
|
11
|
+
allow us to restrict our results based on specific given input.
|
|
12
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
13
|
+
endpoint params:
|
|
14
|
+
|
|
15
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
16
|
+
maximum value will be used.
|
|
17
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
18
|
+
|
|
19
|
+
filter params:
|
|
20
|
+
|
|
21
|
+
- **_name:_** returns research groups that contain in their name the given string
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
In the example below, we are looking for research groups that contain in their name the string _University of Nottingham_.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
research_groups = client.get_research_groups({ 'name' => 'University of Nottingham' })
|
|
29
|
+
puts research_groups
|
|
30
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Get Source
|
|
2
|
+
|
|
3
|
+
_**All answers on WikiRate are sourced.** A source is generally a company report, including CSR Report, Sustainability Report, Annual Report or Integrated Report.
|
|
4
|
+
It could also be a news article, website, conflict mineral report or modern slavery report and so on. A source can be
|
|
5
|
+
added to WikiRate as a URL or file upload. Once a source is added it will remain on the platform so researchers can
|
|
6
|
+
easily access the document._
|
|
7
|
+
|
|
8
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
9
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
10
|
+
|
|
11
|
+
The `get_source` method take as an input either the source name or the source's identifier.
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# get a source by name, returns a Source object
|
|
15
|
+
source = client.get_source("Source-000171202")
|
|
16
|
+
# prints the source as a json
|
|
17
|
+
puts source.to_json
|
|
18
|
+
# prints the raw json response
|
|
19
|
+
puts source.raw_json
|
|
20
|
+
# get a source by id, returns a Source object
|
|
21
|
+
source = client.get_source(13946225)
|
|
22
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
## Get Sources
|
|
2
|
+
|
|
3
|
+
_**All answers on WikiRate are sourced.** A source is generally a company report, including CSR Report, Sustainability
|
|
4
|
+
Report, Annual Report or Integrated Report. It could also be a news article, website, conflict mineral report or modern
|
|
5
|
+
slavery report and so on. A source can be added to WikiRate as a URL or file upload. Once a source is added it will
|
|
6
|
+
remain on the platform so researchers can easily access the document._
|
|
7
|
+
|
|
8
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
9
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
10
|
+
|
|
11
|
+
The `get_sources` method take as an input a `Hash` where the user can define the parameters of their request. More
|
|
12
|
+
specifically, we could divide our params in two different types of parameters, the endpoint parameters and the filter
|
|
13
|
+
parameters. The endpoint parameters help us to iterate through our query's results and the filter parameters allow us to
|
|
14
|
+
restrict our results based on specific given input.
|
|
15
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
16
|
+
endpoint params:
|
|
17
|
+
|
|
18
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
19
|
+
maximum value will be used.
|
|
20
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
21
|
+
|
|
22
|
+
filter params:
|
|
23
|
+
|
|
24
|
+
- **_wikirate_title:_** returns sources that contain in their title the given string
|
|
25
|
+
- **_wikirate_topic_**: returns sources that fall under the defined wikirate topic. All wikirate topics can be
|
|
26
|
+
found [here](https://wikirate.org/Topic).
|
|
27
|
+
- **_year_**: returns sources that referred to the defined year.
|
|
28
|
+
- **_wikirate_link_**: returns sources with where the source is linked to a url that contains the specified string
|
|
29
|
+
- **_company_name_**: returns sources of companies that their name contain the given string.
|
|
30
|
+
- **_report_type_**: returns all sources of the given report type. Allowed parameter values:
|
|
31
|
+
|
|
32
|
+
- 'Aggregate Data Report'
|
|
33
|
+
- 'Annual Report'
|
|
34
|
+
- 'Business Responsibility Report'
|
|
35
|
+
- 'Code of Conduct'
|
|
36
|
+
- 'Communication on Progress'
|
|
37
|
+
- 'Company Website'
|
|
38
|
+
- 'Conflict Minerals Report'
|
|
39
|
+
- 'Corporate Accountability Index'
|
|
40
|
+
- 'Corporate Social Responsibility Report'
|
|
41
|
+
- 'Data Breach Report'
|
|
42
|
+
- 'Gender Pay Gap Report'
|
|
43
|
+
- 'Human Rights Policy Document'
|
|
44
|
+
- 'Integrated Report'
|
|
45
|
+
- 'Member List'
|
|
46
|
+
- 'Modern Slavery Registry Submission'
|
|
47
|
+
- 'Modern Slavery Statement'
|
|
48
|
+
- 'Privacy Policy Document'
|
|
49
|
+
- 'Research Document'
|
|
50
|
+
- 'Responsible Investment Transparency Report'
|
|
51
|
+
- 'Signatory List'
|
|
52
|
+
- 'Standard'
|
|
53
|
+
- 'Supplier List'
|
|
54
|
+
- 'Supply Chain Policy document'
|
|
55
|
+
- 'Sustainability Report'
|
|
56
|
+
- 'Terms of Service'
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
In the example below, we are looking for Conflict Minerals Reports of Nike's for 2021 coming from the sec.gov.
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
sources = client.get_sources({ 'company_name' => 'Nike Inc.',
|
|
64
|
+
'wikirate_title' => 'Conflict Minerals',
|
|
65
|
+
'wikirate_link' => 'sec.gov',
|
|
66
|
+
'year' => 2021 })
|
|
67
|
+
puts sources
|
|
68
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Get Topic
|
|
2
|
+
|
|
3
|
+
_Topics are a way to organize Metrics and other content into thematic groups._
|
|
4
|
+
|
|
5
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
6
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
7
|
+
|
|
8
|
+
The `get_topic` method take as an input either the topic name or the topic's identifier.
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
# get a topic by name, returns a Topic object
|
|
12
|
+
topic = client.get_topic("Wikirate ESG Topics+Environment")
|
|
13
|
+
# prints the topic as a json
|
|
14
|
+
puts topic.to_json
|
|
15
|
+
# prints the raw json response
|
|
16
|
+
puts topic.raw_json
|
|
17
|
+
# get a topic by id, returns a Topic object
|
|
18
|
+
topic = client.get_topic(39152)
|
|
19
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Get Topics
|
|
2
|
+
|
|
3
|
+
_Topics are a way to organize Metrics and other content into thematic groups._
|
|
4
|
+
|
|
5
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
6
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
7
|
+
|
|
8
|
+
The `get_topics` method take as an input a `Hash` where the user can define the parameters of their request. More
|
|
9
|
+
specifically, we could divide our params in two different types of parameters, the endpoint parameters and the filter
|
|
10
|
+
parameters. The endpoint parameters help us to iterate through our query's results and the filter parameters allow us to
|
|
11
|
+
restrict our results based on specific given input.
|
|
12
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
13
|
+
endpoint params:
|
|
14
|
+
|
|
15
|
+
- **_limit:_** default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the
|
|
16
|
+
maximum value will be used.
|
|
17
|
+
- **_offset:_** default value 0, the (zero-based) offset of the first item in the collection to return
|
|
18
|
+
|
|
19
|
+
filter params:
|
|
20
|
+
|
|
21
|
+
- **_name:_** returns topics that contain in their name the given string
|
|
22
|
+
- **_topic_framework:_** returns topics based on the defined Topic Framework, allowed paremeter values:
|
|
23
|
+
|
|
24
|
+
- `Wikirate ESG Topics`
|
|
25
|
+
- `ESRS Standards`
|
|
26
|
+
- `GRI Standards`
|
|
27
|
+
- `UN SDGs`
|
|
28
|
+
- **_bookmark_**: returns the topics you have bookmarked, allowed parameter values:
|
|
29
|
+
|
|
30
|
+
- `bookmark`
|
|
31
|
+
- `nobookmark`
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
In the example below, we are looking for topics that contain on their name the string _environment_.
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
topics = client.get_topics({ 'name' => 'environment' })
|
|
39
|
+
puts topics
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
In the example below, we are looking for topics under the GRI Standards framework.
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
topics = client.get_topics({ 'topic_framework' => 'GRI Standards' })
|
|
46
|
+
puts topics
|
|
47
|
+
```
|
data/examples/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Examples
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
- [Configuration](Configuration.md#configuration)
|
|
5
|
+
- [API-Key](Configuration.md#api-key)
|
|
6
|
+
- [Authentication](Configuration.md#authentication)
|
|
7
|
+
- [Get Company](Get%20Company.md#get-company)
|
|
8
|
+
- [Get Companies](Get%20Companies.md#get-companies)
|
|
9
|
+
- [Add Company](Add%20Company.md#add-company)
|
|
10
|
+
- [Update Company](Update%20Company.md)
|
|
11
|
+
- [Get Metric](Get%20Metric.md#get-metric)
|
|
12
|
+
- [Get Metrics](Get%20Metrics.md#get-metrics)
|
|
13
|
+
- [Get Source](Get%20Source.md#get-source)
|
|
14
|
+
- [Get Sources](Get%20Sources.md#get-sources)
|
|
15
|
+
- [Add Source](Add%20Source.md#add-source)
|
|
16
|
+
- [Update Source](Update%20Source.md#update-source)
|
|
17
|
+
- [Get Answer](Get%20Answer.md#get-answer)
|
|
18
|
+
- [Get Answers](Get%20Answers.md#get-answers)
|
|
19
|
+
- [Add Answer](Add%20Answer.md#add-answer)
|
|
20
|
+
- [Update Answer](Update%20Answer.md)
|
|
21
|
+
- [Get Answers by Metric ID](Get%20Answers.md#get-answers-by-metric-id)
|
|
22
|
+
- [Get Relationship](Get%20Relationship.md#get-relationship)
|
|
23
|
+
- [Get Relationships](Get%20Relationships.md#get-relationships)
|
|
24
|
+
- [Get Relationships by Metric ID](Get%20Relationships.md#get-relationships-by-metric-id)
|
|
25
|
+
- [Add Relationship](Add%20Relationship.md#add-relationship)
|
|
26
|
+
- [Update Relationship](Update%20Relationship.md#update-relationship)
|
|
27
|
+
- [Get Topic](Get%20Topic.md#get-topic)
|
|
28
|
+
- [Get Topics](Get%20Topics.md#get-topics)
|
|
29
|
+
- [Get Dataset](Get%20Dataset.md#get-dataset)
|
|
30
|
+
- [Get Datasets](Get%20Datasets.md#get-datasets)
|
|
31
|
+
- [Get Company Group](Get%20Company%20Group.md#get-company-group)
|
|
32
|
+
- [Get Company Groups](Get%20Company%20Groups.md#get-company-groups)
|
|
33
|
+
- [Get Research Group](Get%20Research%20Group.md#get-research-group)
|
|
34
|
+
- [Get Research Groups](Get%20Research%20Groups.md#get-research-groups)
|
|
35
|
+
- [Get Project](Get%20Project.md#get-project)
|
|
36
|
+
- [Get Projects](Get%20Projects.md#get-projects)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Update Answer
|
|
2
|
+
|
|
3
|
+
_Wikirate platform helps users to find/research answers on specific questions/metrics about companies. Thus, each answer
|
|
4
|
+
is described by the question/metric, company, value, year and source._
|
|
5
|
+
|
|
6
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
7
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
8
|
+
|
|
9
|
+
WikiRate's REST API allows you to update existing answers. wikirate4ruby provides the
|
|
10
|
+
method `update_research_metric_answer` to allow users to import answers on metrics. The method takes as an input a
|
|
11
|
+
number of parameters where all the information about the existing answer is defined. The parameters can be split into
|
|
12
|
+
required and optional.
|
|
13
|
+
|
|
14
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
15
|
+
|
|
16
|
+
required params:
|
|
17
|
+
|
|
18
|
+
- **_metric_designer_**: the designer of the metric we want to add the answer to
|
|
19
|
+
- **_metric_name_**: the metric name/title of the metric we want to add the answer to
|
|
20
|
+
- **_company_**: the company name/id the answer is referred to
|
|
21
|
+
- **_year_**: the year the answer is referred to
|
|
22
|
+
|
|
23
|
+
or
|
|
24
|
+
|
|
25
|
+
- **_answer_id_**: the user can define directly the id of the answer, they want to update, instead of the aformentioned
|
|
26
|
+
paramaters
|
|
27
|
+
|
|
28
|
+
optional params:
|
|
29
|
+
|
|
30
|
+
- **_discussion_**: any comments we might have on the answer
|
|
31
|
+
- **_value_**: the value/answer to the question
|
|
32
|
+
- **_source_**: wikirate's source name of the source we found the answer
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
The example below demonstrates the update of an existing answer. Note that, if the answer does not exist if all the
|
|
37
|
+
required parameters have been defined a new answer will be created (from the example below the source is missing for
|
|
38
|
+
creating a new answer if that answer does not exist)
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
updated_answer = client.update_answer({ 'metric_designer' => 'Walk Free',
|
|
42
|
+
'metric_name' => 'MSA Whistleblowing mechanism',
|
|
43
|
+
'company' => 'AIB Group plc',
|
|
44
|
+
'year' => 2017,
|
|
45
|
+
'value' => 'Supply Chain Workers' })
|
|
46
|
+
```
|
|
47
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## Update Company
|
|
2
|
+
|
|
3
|
+
_Any formal reporting organization (including corporations, NGOs, Universities, etc.) represented as a company on
|
|
4
|
+
Wikirate._
|
|
5
|
+
|
|
6
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
7
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
8
|
+
|
|
9
|
+
WikiRate's REST API allows you not only to create new companies but also to update existing ones. wikirate4ruby provides
|
|
10
|
+
the method `update_company` to allow users updating existing companies. The method takes as an input a number of
|
|
11
|
+
parameters on a `Hash` object and the users need to define the company and the fields they want to update.
|
|
12
|
+
|
|
13
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
14
|
+
|
|
15
|
+
required params:
|
|
16
|
+
|
|
17
|
+
- **_company:_** wikirate company name or identifier
|
|
18
|
+
|
|
19
|
+
optional params:
|
|
20
|
+
|
|
21
|
+
- **_headquarters:_** the region/country the headquarters of the company are located. All the available wikirate Regions
|
|
22
|
+
can be found [here](https://wikirate.org/Regions).
|
|
23
|
+
- **_open_corporates_**: company's open corporates identifier
|
|
24
|
+
- **_wikipedia_**: company's page name on wikipedia
|
|
25
|
+
- **_sec_cik_**: company's central index key as assigned by US Securities and Exchange Commission (SEC)
|
|
26
|
+
- **_os_id:_** company's open supply hub identifier
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
In the example below, we are updating Nike Inc. headquarters location.
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
nike = client.add_company({ 'company' => 'Nike Inc.',
|
|
34
|
+
'headquarters' => 'Oregon (United States)' })
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Instead of the company name we can use the company's identifier when performing updates:
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
nike = client.add_company({ 'company' => 5800,
|
|
41
|
+
'headquarters' => 'Oregon (United States)' })
|
|
42
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
## Update Relationship
|
|
2
|
+
|
|
3
|
+
_Wikirate platform can host answers that respond to relationship questions between companies. For instance, which
|
|
4
|
+
companies supplied company A in 2022? Relationships respond to such questions (metrics with metric type
|
|
5
|
+
Relation Metric)._
|
|
6
|
+
|
|
7
|
+
This example assumes you have configured your Wikirate REST `client`. Instructions on how to configure a client can be
|
|
8
|
+
found in [examples/Configurations.md](https://github.com/wikirate/wikirate4ruby/blob/main/examples/Configuration.md)
|
|
9
|
+
|
|
10
|
+
WikiRate's REST API allows you to not only to import but also update existing relationships. wikirate4ruby provides the
|
|
11
|
+
method `udpate_relationship` to facilitate this functionality. The method takes as an input a number of
|
|
12
|
+
parameters where all the information about the existing relationship and updated fields is defined. The parameters can
|
|
13
|
+
be split into required and optional.
|
|
14
|
+
|
|
15
|
+
<div style="font-family:'Source Code Pro'; font-size:14px; padding-left: 0.5em; padding-right: 0.5em;">
|
|
16
|
+
|
|
17
|
+
required params:
|
|
18
|
+
|
|
19
|
+
- **_metric_designer_**: the designer of the metric
|
|
20
|
+
- **_metric_name_**: the metric name/title of the metric
|
|
21
|
+
- **_subject_company_**: the company name/id of the subject company
|
|
22
|
+
- **_object_company_**: the company name/id of the object company
|
|
23
|
+
- **_year_**: the year the relationship is referred to
|
|
24
|
+
|
|
25
|
+
or
|
|
26
|
+
|
|
27
|
+
- **_answer_id_**: the user can define directly the id of the relationship, they want to update, instead of all the
|
|
28
|
+
aformentioned paramaters
|
|
29
|
+
|
|
30
|
+
optional params:
|
|
31
|
+
|
|
32
|
+
- **_value_**: the value/answer to the question
|
|
33
|
+
- **_source_**: wikirate's source name of the source we found the mentioned relationship
|
|
34
|
+
- **_discussion_**: any comments we might have on the answer
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
The example below demonstrates the import of a relationship to the _Commons_ metric _Supplied By_
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
updated_relationship = client.update_relationship({ 'answer_id' => 6228782,
|
|
42
|
+
'year' => 2018 })
|
|
43
|
+
```
|