Difference between revisions of "API relationships"

From Charitylog Manual
Jump to: navigation, search
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[API Details|Go to API overview]]
 
[[API Details|Go to API overview]]
  
Relationships are created using the clients endpoint. An example call would look like:
+
=Creating Relationships=
 +
Relationships are created by passing the id numbers of the 2 people in the URL. An example call to create a relatiionship between person 37 and person 59 would look like:
  
  [PUT] https<nowiki/>://api.dizions.co.uk/v2/clients/relationship_details/set/37/59
+
  [PUT] https<nowiki/>://api.dizions.co.uk/v2/relationship_details/37/59
[
+
 
  {
+
In the body, these keys are required:
      'id': 44,
+
relation_first_to_second the id of the relationship between the first person and the second person.
      'relation_first_to_second': '6',
+
relation_second_to_first
      'relation_second_to_first': '5',
+
 
      'major': 'Y'
+
There are also optional keys
   }
+
major a Y or N for whether the relationship is a major relationship.
]
+
send_one_letter_to_both a Y or N indicating whether or not to send a single letter if both people are included in a mail merge.
 +
joint_address how to address both people together if send_one_letter_to_both is set to Y.
 +
 
 +
  [
 +
    {
 +
        "relation_first_to_second": "6",
 +
        "relation_second_to_first": "5",
 +
        "major": "Y",
 +
        "send_one_letter_to_both": "Y",
 +
        "joint_address": "Mr and Mrs Smith"
 +
    }
 +
  ]
 +
 
 +
To get a list of relationships, use the dictionary:
 +
 
 +
[GET] https<nowiki/>://api.dizions.co.uk/v2/dictionary/relationships
 +
 
 +
Carer relationships can be created in the same way:
 +
  [
 +
    {
 +
        "relation_first_to_second": "6",
 +
        "relation_second_to_first": "5",
 +
        "carer_relation_first_to_second": "1",
 +
        "carer_relation_second_to_first": "2",
 +
    }
 +
  ]
 +
If the carer relationship is specified, the "standard" relationship must be specified as well, i.e. this is not valid:
 +
   [
 +
    {
 +
        "carer_relation_first_to_second": "1",
 +
        "carer_relation_second_to_first": "2",
 +
    }
 +
  ]
 +
 
 +
To get a list of carer relationships, use the dictionary:
 +
 
 +
[GET] https<nowiki/>://api.dizions.co.uk/v2/dictionary/carer_relationships
 +
 
 +
=Getting relationships=
 +
Relationships can be selected along with other clients fields, like this:
 +
[GET] https<nowiki/>://api.dizions.co.uk/v2/clients/id/37/field/postcode;email;relationship_details

Latest revision as of 10:12, 2 August 2024

Go to API overview

Creating Relationships

Relationships are created by passing the id numbers of the 2 people in the URL. An example call to create a relatiionship between person 37 and person 59 would look like:

[PUT] https://api.dizions.co.uk/v2/relationship_details/37/59

In the body, these keys are required:

relation_first_to_second the id of the relationship between the first person and the second person.
relation_second_to_first

There are also optional keys

major a Y or N for whether the relationship is a major relationship.
send_one_letter_to_both a Y or N indicating whether or not to send a single letter if both people are included in a mail merge.
joint_address how to address both people together if send_one_letter_to_both is set to Y.
 [
   {
       "relation_first_to_second": "6",
       "relation_second_to_first": "5",
       "major": "Y",
       "send_one_letter_to_both": "Y",
       "joint_address": "Mr and Mrs Smith"
   }
 ]

To get a list of relationships, use the dictionary:

[GET] https://api.dizions.co.uk/v2/dictionary/relationships

Carer relationships can be created in the same way:

 [
   {
       "relation_first_to_second": "6",
       "relation_second_to_first": "5",
       "carer_relation_first_to_second": "1",
       "carer_relation_second_to_first": "2",
   }
 ]

If the carer relationship is specified, the "standard" relationship must be specified as well, i.e. this is not valid:

 [
   {
       "carer_relation_first_to_second": "1",
       "carer_relation_second_to_first": "2",
   }
 ]

To get a list of carer relationships, use the dictionary:

[GET] https://api.dizions.co.uk/v2/dictionary/carer_relationships

Getting relationships

Relationships can be selected along with other clients fields, like this:

[GET] https://api.dizions.co.uk/v2/clients/id/37/field/postcode;email;relationship_details