Create Consent For Subscription

Warning: Beta software This API is in beta stage and may be subject to change. Therefore, we do not recommend using this in production.

Interested in this feature? Please reach out to mobility-services-developer@cisco.com

Prerequisites

  1. An OAuth 2.0 client
  2. A client access token

Required Scope

  • subscription.consent:write

Code Dependencies

<dependency>
  <groupId>com.wgtwo.api.v0.grpc</groupId>
  <artifactId>consents</artifactId>
  <version>0.3.0</version>
</dependency>

Code

If targeting production, you would need to add authentication to the sample code.


#!/usr/bin/env bash
grpcurl \
  -d '
  {
    "id": {
      "value": "my_unique_subscription_id_here",
      "tenant": {
        "name": "my_tenant_name_here"
      }
    },
    "productId": "my_product_id_here"
  }' \
  sandbox.api.shamrock.wgtwo.com:443 \
  wgtwo.consents.v0.ConsentService/CreateConsentForSubscription

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.CreateConsentForSubscriptionRequest
import io.grpc.ManagedChannelBuilder

private val channel = ManagedChannelBuilder.forTarget("sandbox.api.shamrock.wgtwo.com:443").build()
private val stub = ConsentServiceGrpc.newBlockingStub(channel)

fun main(vararg args: String) {
    val subscriptionId = "my_unique_subscription_id_here"
    val tenant = "my_tenant_name_here"
    val productId = "my_product_id"
    val request = CreateConsentForSubscriptionRequest.newBuilder().apply {
        this.id = TypesProto.SubscriptionIdentifier.newBuilder().apply {
            this.value = subscriptionId
            this.tenant = TypesProto.Tenant.newBuilder().apply {
                this.name = tenant
            }.build()
        }.build()
        this.productId = productId
    }.build()
    println("Request:
$request")

    val response = stub.createConsentForSubscription(request)
    println("Response:
$response")

    channel.shutdownNow()
}

Example Results Success


{
  "statusCode": "STATUS_CODE_OK"
}

status_code: STATUS_CODE_OK

Example Results Error


{
  "statusCode": "STATUS_CODE_ACCESS_DENIED",
  "errorMessage": "Error message from fake API that matches the status code"
}

status_code: STATUS_CODE_INTERNAL_ERROR
error_message: "Error message from fake API that matches the status code"

Read More