Skip to content
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.0.3"
".": "0.1.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml
openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-9eaed98ce5934f11e901cef376a28257d2c196bd3dba7c690babc6741a730ded.yml
openapi_spec_hash: b76e4e830c4d03ba4cf9429bb9fb9c8a
config_hash: cb5d75abef6264b5d86448caf7295afa
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.1.0 (2025-11-12)

Full Changelog: [v0.0.3...v0.1.0](https://github.com/CASParser/cas-parser-go/compare/v0.0.3...v0.1.0)

### Features

* **api:** api update ([4cafc4e](https://github.com/CASParser/cas-parser-go/commit/4cafc4e634e376310e635eeeacd9c6bc1656d7ca))


### Bug Fixes

* bugfix for setting JSON keys with special characters ([48f9ffd](https://github.com/CASParser/cas-parser-go/commit/48f9ffda3a0053adcf1a68c5378bbeac9de9027c))
* use slices.Concat instead of sometimes modifying r.Options ([c30d79a](https://github.com/CASParser/cas-parser-go/commit/c30d79aa4eb1f8b4d793fe5e641db7d0f385a9dc))


### Chores

* bump minimum go version to 1.22 ([54f1ae1](https://github.com/CASParser/cas-parser-go/commit/54f1ae1bedb207621a92b70a64220456781a8e37))
* do not install brew dependencies in ./scripts/bootstrap by default ([a665c6a](https://github.com/CASParser/cas-parser-go/commit/a665c6aa0d14754a7f4ea644b2b53ac49dec0f0c))
* **internal:** codegen related update ([b0d066b](https://github.com/CASParser/cas-parser-go/commit/b0d066be8e48533c4e0bf3f004c3c6ad96af0008))
* **internal:** grammar fix (it's -> its) ([0af28e9](https://github.com/CASParser/cas-parser-go/commit/0af28e95581cfd4c2d9f729ee59f8213253da54a))
* update more docs for 1.22 ([fc3b56e](https://github.com/CASParser/cas-parser-go/commit/fc3b56e861603f65fd1a61d6c843b220e94154cc))

## 0.0.3 (2025-09-06)

Full Changelog: [v0.0.2...v0.0.3](https://github.com/CASParser/cas-parser-go/compare/v0.0.2...v0.0.3)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ ./scripts/lint

This will install all the required dependencies and build the SDK.

You can also [install go 1.18+ manually](https://go.dev/doc/install).
You can also [install go 1.22+ manually](https://go.dev/doc/install).

## Modifying/Adding code

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/CASParser/cas-parser-go@v0.0.3'
go get -u 'github.com/CASParser/cas-parser-go@v0.1.0'
```

<!-- x-release-please-end -->

## Requirements

This library requires Go 1.18+.
This library requires Go 1.22+.

## Usage

Expand Down Expand Up @@ -128,7 +128,7 @@ custom := param.Override[casparser.FooParams](12)

### Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of it's variants,
Unions are represented as a struct with fields prefixed by "Of" for each of its variants,
only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct.
Expand Down
3 changes: 2 additions & 1 deletion casgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package casparser
import (
"context"
"net/http"
"slices"

"github.com/CASParser/cas-parser-go/internal/apijson"
"github.com/CASParser/cas-parser-go/internal/requestconfig"
Expand Down Expand Up @@ -36,7 +37,7 @@ func NewCasGeneratorService(opts ...option.RequestOption) (r CasGeneratorService
// submitting a mailback request to the specified CAS authority. Currently only
// supports KFintech, with plans to support CAMS, CDSL, and NSDL in the future.
func (r *CasGeneratorService) GenerateCas(ctx context.Context, body CasGeneratorGenerateCasParams, opts ...option.RequestOption) (res *CasGeneratorGenerateCasResponse, err error) {
opts = append(r.Options[:], opts...)
opts = slices.Concat(r.Options, opts)
path := "v4/generate"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand Down
188 changes: 183 additions & 5 deletions casparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package casparser
import (
"context"
"net/http"
"slices"
"time"

"github.com/CASParser/cas-parser-go/internal/apijson"
Expand Down Expand Up @@ -37,7 +38,7 @@ func NewCasParserService(opts ...option.RequestOption) (r CasParserService) {
// Statement) PDF files and returns data in a unified format. Use this endpoint
// when you know the PDF is from CAMS or KFintech.
func (r *CasParserService) CamsKfintech(ctx context.Context, body CasParserCamsKfintechParams, opts ...option.RequestOption) (res *UnifiedResponse, err error) {
opts = append(r.Options[:], opts...)
opts = slices.Concat(r.Options, opts)
path := "v4/cams_kfintech/parse"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -47,7 +48,7 @@ func (r *CasParserService) CamsKfintech(ctx context.Context, body CasParserCamsK
// files and returns data in a unified format. Use this endpoint when you know the
// PDF is from CDSL.
func (r *CasParserService) Cdsl(ctx context.Context, body CasParserCdslParams, opts ...option.RequestOption) (res *UnifiedResponse, err error) {
opts = append(r.Options[:], opts...)
opts = slices.Concat(r.Options, opts)
path := "v4/cdsl/parse"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -57,7 +58,7 @@ func (r *CasParserService) Cdsl(ctx context.Context, body CasParserCdslParams, o
// files and returns data in a unified format. Use this endpoint when you know the
// PDF is from NSDL.
func (r *CasParserService) Nsdl(ctx context.Context, body CasParserNsdlParams, opts ...option.RequestOption) (res *UnifiedResponse, err error) {
opts = append(r.Options[:], opts...)
opts = slices.Concat(r.Options, opts)
path := "v4/nsdl/parse"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -68,7 +69,7 @@ func (r *CasParserService) Nsdl(ctx context.Context, body CasParserNsdlParams, o
// CAS type and transforms the data into a consistent structure regardless of the
// source.
func (r *CasParserService) SmartParse(ctx context.Context, body CasParserSmartParseParams, opts ...option.RequestOption) (res *UnifiedResponse, err error) {
opts = append(r.Options[:], opts...)
opts = slices.Concat(r.Options, opts)
path := "v4/smart/parse"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -80,14 +81,17 @@ type UnifiedResponse struct {
Investor UnifiedResponseInvestor `json:"investor"`
Meta UnifiedResponseMeta `json:"meta"`
MutualFunds []UnifiedResponseMutualFund `json:"mutual_funds"`
Summary UnifiedResponseSummary `json:"summary"`
// List of NPS accounts
Nps []UnifiedResponseNp `json:"nps"`
Summary UnifiedResponseSummary `json:"summary"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
DematAccounts respjson.Field
Insurance respjson.Field
Investor respjson.Field
Meta respjson.Field
MutualFunds respjson.Field
Nps respjson.Field
Summary respjson.Field
ExtraFields map[string]respjson.Field
raw string
Expand Down Expand Up @@ -116,6 +120,8 @@ type UnifiedResponseDematAccount struct {
// Depository Participant name
DpName string `json:"dp_name"`
Holdings UnifiedResponseDematAccountHoldings `json:"holdings"`
// List of account holders linked to this demat account
LinkedHolders []UnifiedResponseDematAccountLinkedHolder `json:"linked_holders"`
// Total value of the demat account
Value float64 `json:"value"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
Expand All @@ -127,6 +133,7 @@ type UnifiedResponseDematAccount struct {
DpID respjson.Field
DpName respjson.Field
Holdings respjson.Field
LinkedHolders respjson.Field
Value respjson.Field
ExtraFields map[string]respjson.Field
raw string
Expand Down Expand Up @@ -347,6 +354,26 @@ func (r *UnifiedResponseDematAccountHoldingsGovernmentSecurity) UnmarshalJSON(da
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseDematAccountLinkedHolder struct {
// Name of the account holder
Name string `json:"name"`
// PAN of the account holder
Pan string `json:"pan"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
Pan respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseDematAccountLinkedHolder) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseDematAccountLinkedHolder) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseInsurance struct {
LifeInsurancePolicies []UnifiedResponseInsuranceLifeInsurancePolicy `json:"life_insurance_policies"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
Expand Down Expand Up @@ -490,6 +517,8 @@ type UnifiedResponseMutualFund struct {
Amc string `json:"amc"`
// Folio number
FolioNumber string `json:"folio_number"`
// List of account holders linked to this mutual fund folio
LinkedHolders []UnifiedResponseMutualFundLinkedHolder `json:"linked_holders"`
// Registrar and Transfer Agent name
Registrar string `json:"registrar"`
Schemes []UnifiedResponseMutualFundScheme `json:"schemes"`
Expand All @@ -500,6 +529,7 @@ type UnifiedResponseMutualFund struct {
AdditionalInfo respjson.Field
Amc respjson.Field
FolioNumber respjson.Field
LinkedHolders respjson.Field
Registrar respjson.Field
Schemes respjson.Field
Value respjson.Field
Expand Down Expand Up @@ -538,6 +568,26 @@ func (r *UnifiedResponseMutualFundAdditionalInfo) UnmarshalJSON(data []byte) err
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseMutualFundLinkedHolder struct {
// Name of the account holder
Name string `json:"name"`
// PAN of the account holder
Pan string `json:"pan"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
Pan respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseMutualFundLinkedHolder) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseMutualFundLinkedHolder) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseMutualFundScheme struct {
// Additional information specific to the scheme
AdditionalInfo UnifiedResponseMutualFundSchemeAdditionalInfo `json:"additional_info"`
Expand Down Expand Up @@ -676,6 +726,112 @@ func (r *UnifiedResponseMutualFundSchemeTransaction) UnmarshalJSON(data []byte)
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseNp struct {
// Additional information specific to the NPS account
AdditionalInfo any `json:"additional_info"`
// Central Record Keeping Agency name
Cra string `json:"cra"`
Funds []UnifiedResponseNpFund `json:"funds"`
// List of account holders linked to this NPS account
LinkedHolders []UnifiedResponseNpLinkedHolder `json:"linked_holders"`
// Permanent Retirement Account Number (PRAN)
Pran string `json:"pran"`
// Total value of the NPS account
Value float64 `json:"value"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AdditionalInfo respjson.Field
Cra respjson.Field
Funds respjson.Field
LinkedHolders respjson.Field
Pran respjson.Field
Value respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseNp) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseNp) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseNpFund struct {
// Additional information specific to the NPS fund
AdditionalInfo UnifiedResponseNpFundAdditionalInfo `json:"additional_info"`
// Cost of investment
Cost float64 `json:"cost"`
// Name of the NPS fund
Name string `json:"name"`
// Net Asset Value per unit
Nav float64 `json:"nav"`
// Number of units held
Units float64 `json:"units"`
// Current market value of the holding
Value float64 `json:"value"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AdditionalInfo respjson.Field
Cost respjson.Field
Name respjson.Field
Nav respjson.Field
Units respjson.Field
Value respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseNpFund) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseNpFund) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Additional information specific to the NPS fund
type UnifiedResponseNpFundAdditionalInfo struct {
// Fund manager name
Manager string `json:"manager"`
// NPS tier (Tier I or Tier II)
//
// Any of 1, 2.
Tier float64 `json:"tier,nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Manager respjson.Field
Tier respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseNpFundAdditionalInfo) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseNpFundAdditionalInfo) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseNpLinkedHolder struct {
// Name of the account holder
Name string `json:"name"`
// PAN of the account holder
Pan string `json:"pan"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Name respjson.Field
Pan respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseNpLinkedHolder) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseNpLinkedHolder) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseSummary struct {
Accounts UnifiedResponseSummaryAccounts `json:"accounts"`
// Total portfolio value across all accounts
Expand All @@ -699,11 +855,13 @@ type UnifiedResponseSummaryAccounts struct {
Demat UnifiedResponseSummaryAccountsDemat `json:"demat"`
Insurance UnifiedResponseSummaryAccountsInsurance `json:"insurance"`
MutualFunds UnifiedResponseSummaryAccountsMutualFunds `json:"mutual_funds"`
Nps UnifiedResponseSummaryAccountsNps `json:"nps"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Demat respjson.Field
Insurance respjson.Field
MutualFunds respjson.Field
Nps respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
Expand Down Expand Up @@ -775,6 +933,26 @@ func (r *UnifiedResponseSummaryAccountsMutualFunds) UnmarshalJSON(data []byte) e
return apijson.UnmarshalRoot(data, r)
}

type UnifiedResponseSummaryAccountsNps struct {
// Number of NPS accounts
Count int64 `json:"count"`
// Total value of NPS accounts
TotalValue float64 `json:"total_value"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
TotalValue respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r UnifiedResponseSummaryAccountsNps) RawJSON() string { return r.JSON.raw }
func (r *UnifiedResponseSummaryAccountsNps) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type CasParserCamsKfintechParams struct {
// Password for the PDF file (if required)
Password param.Opt[string] `json:"password,omitzero"`
Expand Down
Loading