Skip to content

Latest commit

 

History

History
321 lines (273 loc) · 24.3 KB

README.md

File metadata and controls

321 lines (273 loc) · 24.3 KB

Go API client for github.com/mydatamyconsent/sdk

Unleashing the power of consent by establishing trust. The Platform Core Developer API defines a set of capabilities that can be used to request, issue, manage and update data, documents and credentials by organizations. The API can be used to request, manage and update Decentralised Identifiers, Financial Data, Health Data issue Documents, Credentials directly or using OpenID Connect flows, and verify Messages signed with DIDs and much more.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import github.com/mydatamyconsent/sdk "github.com/mydatamyconsent/go-sdk"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), github.com/mydatamyconsent/sdk.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), github.com/mydatamyconsent/sdk.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), github.com/mydatamyconsent/sdk.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), github.com/mydatamyconsent/sdk.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.mydatamyconsent.com

Class Method HTTP request Description
DataProcessingAgreementsApi V1DataAgreementsGet Get /v1/data-agreements Get paginated data processing agreements.
DataProcessingAgreementsApi V1DataAgreementsIdDelete Delete /v1/data-agreements/{id} Delete a data processing agreement this will not delete a published or a agreement in use with consents.
DataProcessingAgreementsApi V1DataAgreementsIdGet Get /v1/data-agreements/{id} Get data processing agreement by id.
DataProcessingAgreementsApi V1DataAgreementsIdTerminatePut Put /v1/data-agreements/{id}/terminate Terminate a data processing agreement by id.
DataProvidersDiscoveryApi V1DataProvidersGet Get /v1/data-providers Discover all data providers in my data my consent by country and filters.
DataProvidersDiscoveryApi V1DataProvidersIdGet Get /v1/data-providers/{id} Get a data provider details by provider id.
IndividualsApi IssuerIssuedoc1XmlPost Post /issuer/issuedoc/1/xml Digilocker compatible endpoint to issue document.
IndividualsApi V1IndividualsConsentRequestsGet Get /v1/individuals/consent-requests Get all consent requests sent to Individuals.
IndividualsApi V1IndividualsConsentRequestsPost Post /v1/individuals/consent-requests Create individual consent request.
IndividualsApi V1IndividualsConsentRequestsRequestIdCancelPut Put /v1/individuals/consent-requests/{request_id}/cancel Cancel the Individual data request by id.
IndividualsApi V1IndividualsConsentRequestsRequestIdGet Get /v1/individuals/consent-requests/{request_id} Get Individual data consent request by id.
IndividualsApi V1IndividualsConsentTemplatesGet Get /v1/individuals/consent-templates Get the paginated list of individual consent templates.
IndividualsApi V1IndividualsConsentTemplatesTemplateIdGet Get /v1/individuals/consent-templates/{template_id} Get Individual consent template details by consent id.
IndividualsApi V1IndividualsConsentsConsentIdDocumentsDocumentIdDownloadGet Get /v1/individuals/consents/{consent_id}/documents/{document_id}/download Download Individual consented document by document id.
IndividualsApi V1IndividualsConsentsConsentIdDocumentsDocumentIdGet Get /v1/individuals/consents/{consent_id}/documents/{document_id} Get Individual consented document by document id.
IndividualsApi V1IndividualsConsentsConsentIdDocumentsGet Get /v1/individuals/consents/{consent_id}/documents Get Individual consented document by consent id.
IndividualsApi V1IndividualsConsentsConsentIdFinancialAccountsAccountIdGet Get /v1/individuals/consents/{consent_id}/financial-accounts/{account_id} Get individual consented financial account details.
IndividualsApi V1IndividualsConsentsConsentIdFinancialAccountsAccountIdTransactionsGet Get /v1/individuals/consents/{consent_id}/financial-accounts/{account_id}/transactions Get individual consented financial account transactions.
IndividualsApi V1IndividualsConsentsConsentIdFinancialAccountsGet Get /v1/individuals/consents/{consent_id}/financial-accounts Get all individual consented financial accounts.
IndividualsApi V1IndividualsConsentsConsentIdGet Get /v1/individuals/consents/{consent_id} Get Individuals consent details by consent id.
IndividualsApi V1IndividualsConsentsConsentIdHealthFhirBundleGet Get /v1/individuals/consents/{consent_id}/health/fhir/bundle Get Individual consented Health Records by consent id.
IndividualsApi V1IndividualsConsentsGet Get /v1/individuals/consents Get the paginated list of Individual consents.
IndividualsApi V1IndividualsDocumentsIssueIssueRequestIdUploadPost Post /v1/individuals/documents/issue/{issue_request_id}/upload Upload a document for issuance request of individual.
IndividualsApi V1IndividualsDocumentsIssuePost Post /v1/individuals/documents/issue Issue a new document to an individual user.
IndividualsApi V1IndividualsDocumentsIssuedDocumentIdGet Get /v1/individuals/documents/issued/{document_id} Get issued document.
IndividualsApi V1IndividualsDocumentsIssuedGet Get /v1/individuals/documents/issued Get paginated list of issued documents of given document type.
IndividualsApi V1IndividualsDocumentsTypesGet Get /v1/individuals/documents/types Get paginated list of registered document types.
OrganizationsApi V1OrganizationsConsentRequestsGet Get /v1/organizations/consent-requests Get all consent requests sent to Organizations.
OrganizationsApi V1OrganizationsConsentRequestsPost Post /v1/organizations/consent-requests Create consent request for an Organization.
OrganizationsApi V1OrganizationsConsentRequestsRequestIdCancelPut Put /v1/organizations/consent-requests/{request_id}/cancel Cancel the Organization data request by id.
OrganizationsApi V1OrganizationsConsentRequestsRequestIdGet Get /v1/organizations/consent-requests/{request_id} Get Organization data request by id.
OrganizationsApi V1OrganizationsConsentTemplatesGet Get /v1/organizations/consent-templates Get the paginated list of organization consent templates.
OrganizationsApi V1OrganizationsConsentTemplatesTemplateIdGet Get /v1/organizations/consent-templates/{template_id} Get Organization consent template details by consent id.
OrganizationsApi V1OrganizationsConsentsConsentIdDocumentsDocumentIdDownloadGet Get /v1/organizations/consents/{consent_id}/documents/{document_id}/download Download Organization consent document by document id.
OrganizationsApi V1OrganizationsConsentsConsentIdDocumentsDocumentIdGet Get /v1/organizations/consents/{consent_id}/documents/{document_id} Get Organization consent document based on document id and consent id.
OrganizationsApi V1OrganizationsConsentsConsentIdDocumentsGet Get /v1/organizations/consents/{consent_id}/documents Get Organization consent document by consent id.
OrganizationsApi V1OrganizationsConsentsConsentIdFinancialAccountsAccountIdGet Get /v1/organizations/consents/{consent_id}/financial-accounts/{account_id} Get organization consented financial account details.
OrganizationsApi V1OrganizationsConsentsConsentIdFinancialAccountsAccountIdTransactionsGet Get /v1/organizations/consents/{consent_id}/financial-accounts/{account_id}/transactions Get organization consented financial account transactions.
OrganizationsApi V1OrganizationsConsentsConsentIdFinancialAccountsGet Get /v1/organizations/consents/{consent_id}/financial-accounts Get all organization consented financial accounts.
OrganizationsApi V1OrganizationsConsentsConsentIdGet Get /v1/organizations/consents/{consent_id} Get Organization consent request details by consent id.
OrganizationsApi V1OrganizationsConsentsGet Get /v1/organizations/consents Get the paginated list of Organization consents.
OrganizationsApi V1OrganizationsDocumentsIssuePost Post /v1/organizations/documents/issue Issue a new document to an organization.
OrganizationsApi V1OrganizationsDocumentsIssueUploadIssueRequestIdPost Post /v1/organizations/documents/issue/upload/{issue_request_id} Upload a document for issuance request of Organization.
OrganizationsApi V1OrganizationsDocumentsIssuedDocumentIdGet Get /v1/organizations/documents/issued/{document_id} Get issued document.
OrganizationsApi V1OrganizationsDocumentsIssuedGet Get /v1/organizations/documents/issued Get paginated list of issued documents of given document type.
OrganizationsApi V1OrganizationsDocumentsTypesGet Get /v1/organizations/documents/types Get paginated list of registered document types.
SupportedIdentifiersApi V1SupportedIdentifiersCountryIso2CodeGet Get /v1/supported-identifiers/{country_iso2_code} Get all supported identifiers by country.

Documentation For Models

Documentation For Authorization

OAuth2ClientCredentials

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
  • SupportedIdentifiers:Read: Read SupportedIdentifiers.
  • DataProviders:Read: Read DataProviders.
  • DataProcessingAgreements:Read: Read DataProcessingAgreements.
  • DataProcessingAgreements:Write: Read & Write DataProcessingAgreements.
  • Individuals:DocumentTypes:Read: Read Individual DocumentTypes.
  • Individuals:Documents:Read: Read Individual Issued Documents.
  • Individuals:Documents:Issue: Issue Individual Documents.
  • Organizations:DocumentTypes:Read: Read Organization DocumentTypes.
  • Organizations:Documents:Read: Read Organization Issued Documents.
  • Organizations:Documents:Issue: Issue Organization Documents.
  • Individuals:ConsentRequests:Request: Request Individual Consent requests.
  • Individuals:ConsentRequests:Cancel: Cancel Individual Consent requests.
  • Individuals:ConsentRequests:Read: Read Individual Consent requests.
  • Organizations:ConsentRequests:Request: Request Organization Consent requests.
  • Organizations:ConsentRequests:Cancel: Cancel Organization Consent requests.
  • Organizations:ConsentRequests:Read: Read Organization Consent requests.
  • Individuals:Consents:Read: Read Individual Consents.
  • Organizations:Consents:Read: Read Organization Consents.
  • Individuals:ConsentRequestTemplates:Read: Read Individual Consent Request templates.
  • Organizations:ConsentRequestTemplates:Read: Read Organization Consent Request templates.

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]