Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phonum 1568 #83

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ type Meta struct {
Limit int64
}

type BaseListParams struct {
Limit int `json:"limit,omitempty" url:"limit,omitempty"`
Offset int `json:"offset,omitempty" url:"offset,omitempty"`
}

type BaseListResponse struct {
ApiID string `json:"api_id" url:"api_id"`
Meta Meta `json:"meta" url:"meta"`
Expand Down
163 changes: 163 additions & 0 deletions compliance_applications.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
package plivo

import "time"

type ComplianceApplicationService struct {
client *Client
}

type SubmitComplianceApplicationResponse struct {
APIID string `json:"api_id"`
CreatedAt time.Time `json:"created_at"`
ComplianceApplicationID string `json:"compliance_application_id"`
Alias string `json:"alias"`
Status string `json:"status"`
EndUserType string `json:"end_user_type"`
CountryIso2 string `json:"country_iso2"`
NumberType string `json:"number_type"`
EndUserID string `json:"end_user_id"`
ComplianceRequirementID string `json:"compliance_requirement_id"`
Documents []struct {
DocumentID string `json:"document_id"`
Name string `json:"name"`
DocumentName string `json:"document_name,omitempty"`
DocumentTypeID string `json:"document_type_id,omitempty"`
DocumentTypeName string `json:"document_type_name,omitempty"`
Scope string `json:"scope,omitempty"`
} `json:"documents"`
}

type UpdateComplianceApplicationParams struct {
ComplianceApplicationId string `json:"compliance_application_id"`
DocumentIds []string `json:"document_ids"`
}

type UpdateComplianceApplicationResponse BaseResponse

type CreateComplianceApplicationParams struct {
ComplianceRequirementId string `json:"compliance_requirement_id,omitempty" url:"compliance_requirement_id,omitempty"`
EndUserId string `json:"end_user_id,omitempty" url:"end_user_id,omitempty"`
DocumentIds []string `json:"document_ids,omitempty" url:"document_ids, omitempty"`
Alias string `json:"alias,omitempty" url:"alias, omitempty"`
EndUserType string `json:"end_user_type,omitempty" url:"end_user_type, omitempty"`
CountryIso2 string `json:"country_iso2,omitempty" url:"country_iso2, omitempty"`
NumberType string `json:"number_type,omitempty" url:"number_type, omitempty"`
}

type ComplianceApplicationResponse struct {
APIID string `json:"api_id"`
CreatedAt time.Time `json:"created_at"`
ComplianceApplicationID string `json:"compliance_application_id"`
Alias string `json:"alias"`
Status string `json:"status"`
EndUserType string `json:"end_user_type"`
CountryIso2 string `json:"country_iso2"`
NumberType string `json:"number_type"`
EndUserID string `json:"end_user_id"`
ComplianceRequirementID string `json:"compliance_requirement_id"`
Documents []struct {
DocumentID string `json:"document_id"`
Name string `json:"name"`
DocumentName string `json:"document_name,omitempty"`
DocumentTypeID string `json:"document_type_id,omitempty"`
DocumentTypeName string `json:"document_type_name,omitempty"`
Scope string `json:"scope,omitempty"`
} `json:"documents"`
}

type ComplianceApplicationListParams struct {
Limit int `json:"limit,omitempty" url:"limit,omitempty"`
Offset int `json:"offset,omitempty" url:"offset,omitempty"`
EndUserID string `json:"end_user_id,omitempty" url:"end_user_id,omitempty"`
Country string `json:"country,omitempty" url:"country,omitempty"`
NumberType string `json:"number_type,omitempty" url:"number_type,omitempty"`
EndUserType string `json:"end_user_type,omitempty" url:"end_user_type,omitempty"`
Alias string `json:"alias,omitempty" url:"alias,omitempty"`
Status string `json:"status,omitempty" url:"status,omitempty"`
}

type ListComplianceApplicationResponse struct {
APIID string `json:"api_id"`
Meta struct {
Limit int `json:"limit"`
Next string `json:"next"`
Offset int `json:"offset"`
Previous interface{} `json:"previous"`
TotalCount int `json:"total_count"`
} `json:"meta"`
Objects []struct {
CreatedAt time.Time `json:"created_at"`
ComplianceApplicationID string `json:"compliance_application_id"`
Alias string `json:"alias"`
Status string `json:"status"`
EndUserType string `json:"end_user_type"`
CountryIso2 string `json:"country_iso2"`
NumberType string `json:"number_type"`
EndUserID string `json:"end_user_id"`
ComplianceRequirementID string `json:"compliance_requirement_id"`
Documents []struct {
DocumentID string `json:"document_id"`
Name string `json:"name"`
DocumentName string `json:"document_name"`
DocumentTypeID string `json:"document_type_id"`
DocumentTypeName string `json:"document_type_name"`
Scope string `json:"scope"`
} `json:"documents"`
} `json:"objects"`
}

func (service *ComplianceApplicationService) Get(complianceApplicationId string) (response *ComplianceApplicationResponse, err error) {
req, err := service.client.NewRequest("GET", nil, "ComplianceApplication/%s", complianceApplicationId)
response = &ComplianceApplicationResponse{}
err = service.client.ExecuteRequest(req, response)
return
}

func (service *ComplianceApplicationService) List(params ComplianceApplicationListParams) (response *ListComplianceApplicationResponse, err error) {
request, err := service.client.NewRequest("GET", params, "ComplianceApplication")
if err != nil {
return
}
response = &ListComplianceApplicationResponse{}
err = service.client.ExecuteRequest(request, response)
return
}

func (service *ComplianceApplicationService) Create(params CreateComplianceApplicationParams) (response *ComplianceApplicationResponse, err error) {
request, err := service.client.NewRequest("POST", params, "ComplianceApplication")
if err != nil {
return
}
response = &ComplianceApplicationResponse{}
err = service.client.ExecuteRequest(request, response)
return
}

func (service *ComplianceApplicationService) Update(params UpdateComplianceApplicationParams) (response *UpdateComplianceApplicationResponse, err error) {
request, err := service.client.NewRequest("POST", params, "ComplianceApplication/%s", params.ComplianceApplicationId)
if err != nil {
return
}
response = &UpdateComplianceApplicationResponse{}
err = service.client.ExecuteRequest(request, response)
return
}

func (service *ComplianceApplicationService) Delete(complianceApplicationId string) (err error) {
req, err := service.client.NewRequest("DELETE", nil, "ComplianceApplication/%s", complianceApplicationId)
if err != nil {
return
}
err = service.client.ExecuteRequest(req, nil)
return
}

func (service *ComplianceApplicationService) Submit(complianceApplicationId string) (response *SubmitComplianceApplicationResponse, err error) {
req, err := service.client.NewRequest("POST", nil, "ComplianceApplication/%s/Submit", complianceApplicationId)
if err != nil {
return
}
response = &SubmitComplianceApplicationResponse{}
err = service.client.ExecuteRequest(req, response)
return
}
71 changes: 71 additions & 0 deletions compliance_document_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package plivo

import "time"

type ComplianceDocumentTypeService struct {
client *Client
}

type GetComplianceDocumentTypeResponse struct {
APIID string `json:"api_id"`
CreatedAt time.Time `json:"created_at"`
Description string `json:"description"`
DocumentName string `json:"document_name"`
DocumentTypeID string `json:"document_type_id"`
Information []struct {
FieldName string `json:"field_name"`
FieldType string `json:"field_type"`
FriendlyName string `json:"friendly_name"`
HelpText string `json:"help_text,omitempty"`
MaxLength int `json:"max_length,omitempty"`
MinLength int `json:"min_length,omitempty"`
Format string `json:"format,omitempty"`
Enums []string `json:"enums,omitempty"`
} `json:"information"`
ProofRequired interface{} `json:"proof_required"`
}

type ListComplianceDocumentTypeResponse struct {
APIID string `json:"api_id"`
Meta struct {
Limit int `json:"limit"`
Next interface{} `json:"next"`
Offset int `json:"offset"`
Previous interface{} `json:"previous"`
TotalCount int `json:"total_count"`
} `json:"meta"`
Objects []struct {
CreatedAt time.Time `json:"created_at"`
Description string `json:"description"`
DocumentName string `json:"document_name"`
DocumentTypeID string `json:"document_type_id"`
Information []struct {
FieldName string `json:"field_name"`
FieldType string `json:"field_type"`
Format string `json:"format,omitempty"`
FriendlyName string `json:"friendly_name"`
MaxLength int `json:"max_length,omitempty"`
MinLength int `json:"min_length,omitempty"`
HelpText string `json:"help_text,omitempty"`
Enums []string `json:"enums,omitempty"`
} `json:"information"`
ProofRequired interface{} `json:"proof_required"`
} `json:"objects"`
}

func (service *ComplianceDocumentTypeService) Get(docId string) (response *GetComplianceDocumentTypeResponse, err error) {
req, err := service.client.NewRequest("GET", nil, "ComplianceDocumentType/%s", docId)
response = &GetComplianceDocumentTypeResponse{}
err = service.client.ExecuteRequest(req, response)
return
}

func (service *ComplianceDocumentTypeService) List(params BaseListParams) (response *ListComplianceDocumentTypeResponse, err error) {
request, err := service.client.NewRequest("GET", params, "ComplianceDocumentType")
if err != nil {
return
}
response = &ListComplianceDocumentTypeResponse{}
err = service.client.ExecuteRequest(request, response)
return
}
Loading