Get consents for a subscription
WARNING
This API is in alpha and is subject to change. We do not recommend using this in production.
Prerequisites
Required scope
subscription.consent:read
Code
TIP
You can test our APIs without authorization by targetting sandbox.api.wgtwo.com
instead of api.wgtwo.com
and removing any authorization from the request/code sample.
Download proto definitions
curl -sL 'https://github.com/working-group-two/wgtwoapis/blob/master/image.bin?raw=true' -o wgtwo.bin
1
export ACCESS_TOKEN="my_client_access_token"
grpcurl -protoset wgtwo.bin \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '
{
"id": {
"value": "my_unique_subscription_id_here",
"tenant": {
"name": "my_tenant_name_here"
}
}
}' \
api.wgtwo.com:443 \
wgtwo.consents.v0.ConsentService/GetConsentsForSubscription
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Example result
{
"products": [
{
"id": "3",
"name": "Product 3",
"subtitle": "Product 3 subtitle",
"productUrl": "https://product3.example",
"description": "Product 3 description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
},
{
"id": "1",
"name": "Product 1",
"subtitle": "Product 1 subtitle",
"productUrl": "https://product1.example",
"description": "Product 1 description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Install dependencies
Maven
<dependency>
<groupId>com.wgtwo.api.v0.grpc</groupId>
<artifactId>consents</artifactId>
<version>0.1.10</version>
</dependency>
package com.example.consents
import com.wgtwo.api.v0.common.TypesProto
import com.wgtwo.api.v0.consent.ConsentServiceGrpc
import com.wgtwo.api.v0.consent.ConsentsProto.GetConsentsForSubscriptionRequest
import com.wgtwo.auth.BearerTokenCallCredentials
import io.grpc.ManagedChannelBuilder
/** Use the sandbox environment for testing without authentication */
private val environment = Environment.SANDBOX
private val endpoint = when (environment) {
Environment.SANDBOX -> "sandbox.api.wgtwo.com"
Environment.PRODUCTION -> "api.wgtwo.com"
}
private val channel = ManagedChannelBuilder.forAddress(endpoint, 443).build()
private val stub = ConsentServiceGrpc.newBlockingStub(channel).apply {
/**
* If you are not using the sandbox, you need to add credentials.
* The BearerTokenCallCredentials class can be found in our auth library.
*/
if (environment == Environment.PRODUCTION) {
this.withCallCredentials(BearerTokenCallCredentials { "MY_CLIENT_ACCESS_TOKEN" })
}
}
fun main(vararg args: String) {
val subscriptionId = "my_unique_subscription_id_here"
val tenant = "my_tenant_name_here"
val request = GetConsentsForSubscriptionRequest.newBuilder().apply {
this.id = TypesProto.SubscriptionIdentifier.newBuilder().apply {
this.value = subscriptionId
this.tenant = TypesProto.Tenant.newBuilder().apply {
this.name = tenant
}.build()
}.build()
}.build()
println("Request:\n$request")
val response = stub.getConsentsForSubscription(request)
println("Response:\n$response")
channel.shutdownNow()
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Example result
consents {
owner {
tenant {
name: "my_tenant_name_here"
}
}
product_id: "976"
scopes {
property: "products.tenant:read"
}
scopes {
property: "phone"
}
scopes {
}
scopes {
property: "events.periodic_country.subscribe"
}
scopes {
property: "subscription.periodic_country:read"
}
scopes {
property: "subscription.read"
}
scopes {
property: "call.routing:write"
}
scopes {
property: "events.voicemail.subscribe"
}
scopes {
property: "subscription.id:read"
}
}
consents {
owner {
tenant {
name: "my_tenant_name_here"
}
}
product_id: "156"
scopes {
property: "data.content_filtering:write"
}
scopes {
property: "callforwarding.to_voicemail"
}
scopes {
property: "events.location.subscribe"
}
scopes {
property: "callforwarding.to_number"
}
scopes {
property: "events.handset_update.subscribe"
}
scopes {
property: "voicemail.update"
}
scopes {
property: "subscription.periodic_country:read"
}
scopes {
property: "sms.data:send_to_subscriber"
}
}
status_code: STATUS_CODE_OK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67