• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArrowSphere / nodejs-api-client / #8615

23 May 2025 12:49PM UTC coverage: 95.245% (+0.004%) from 95.241%
#8615

Pull #684

tbottini-arrow
ARE-48053-fix(subscriptions): list should returns partner subscriptions
Pull Request #684: ARE-48053-fix(subscriptions): list should returns partner subscriptions

1384 of 1516 branches covered (91.29%)

Branch coverage included in aggregate %.

6 of 7 new or added lines in 2 files covered. (85.71%)

7129 of 7422 relevant lines covered (96.05%)

7.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.0
/src/subscriptions/subscriptionsClient.ts
1
/**
2
 * Class SubscriptionsClient
3
 */
4
import { AbstractRestfulClient } from '../abstractRestfulClient';
1✔
5
import { SubscriptionData } from './entities/subscription';
6
import { SubscriptionsListResult } from './entities/subscriptionsListResult';
1✔
7

8
export type SubscriptionsListPayload = {
9
  subscription?: string[];
10
  status?: string[];
11
  partnerTag?: string[];
12
  marketplace?: string[];
13
  company?: string[];
14
  startDate?: string;
15
  endingDate?: string;
16
  lastUpdate?: string;
17
  perPage?: string;
18
  page?: string;
19
  sortBy?: string;
20
  sortDirection?: 'ASC' | 'DESC';
21
};
22

23
export type SubscriptionsListData = {
24
  data: Array<SubscriptionData>;
25
  pagination: {
26
    perPage: number;
27
    currentPage: number;
28
    totalPage: number;
29
    total: number;
30
    next: string;
31
    previous: string;
32
  };
33
};
34

35
export type SubscriptionCreationData = {
36
  name: string;
37
  level: string;
38
  sku: string;
39
  extraInformation?: {
40
    programs: {
41
      [programName: string]: Record<string, string | boolean>;
42
    };
43
  };
44
};
45

46
export class SubscriptionsClient extends AbstractRestfulClient {
1✔
47
  /**
48
   * The base path of the API
49
   */
50
  protected basePath = '/subscriptions';
2✔
51

52
  /**
53
   * The path of the List endpoint
54
   */
55
  private LIST_PATH = '';
2✔
56

57
  /**
58
   * Pagination for these endpoints are camel cased (`&perPage=x` instead of `&per_page=x`)
59
   */
60
  protected isCamelPagination = true;
2✔
61

62
  /**
63
   * Calls the subscriptions API list endpoint
64
   *
65
   * @param data - List payload
66
   *
67
   * @returns Promise\<AxiosResponse\<{@link SubscriptionsListData}\>\>   */
68
  public async listRaw(
69
    data: SubscriptionsListPayload = {},
1✔
70
    options = { isAdmin: false },
4✔
71
  ): Promise<SubscriptionsListData> {
72
    this.path = this.LIST_PATH;
13✔
73
    return this.get<SubscriptionsListData>(data, {}, options);
13✔
74
  }
75

76
  /**
77
   * Lists subscriptions and returns a SubscriptionsListResult to manipulate the results.
78
   *
79
   * Note: This endpoint requires an admin token to be called
80
   *
81
   * @param postData - List payload
82
   * @param perPage - Number of results per page
83
   * @param page - Page number to fetch
84
   *
85
   * @returns Promise\<{@link SubscriptionsListResult}\>
86
   *
87
   */
88
  public async list(
89
    postData: SubscriptionsListPayload = {},
4✔
90
    perPage = 100,
3✔
91
    page = 1,
3✔
92
  ): Promise<SubscriptionsListResult> {
93
    this.setPerPage(perPage);
4✔
94
    this.setPage(page);
4✔
95

96
    const response = await this.listRaw(postData, { isAdmin: false });
4✔
97

98
    return new SubscriptionsListResult(response, this, postData);
4✔
99
  }
100

101
  public async listAdmin(
102
    postData: SubscriptionsListPayload = {},
4✔
103
    perPage = 100,
3✔
104
    page = 1,
3✔
105
  ) {
106
    this.setPerPage(perPage);
4✔
107
    this.setPage(page);
4✔
108

109
    const response = await this.listRaw(postData, { isAdmin: true });
4✔
110

111
    return new SubscriptionsListResult(response, this, postData);
4✔
112
  }
113

114
  public async addSubscription(
115
    postData: SubscriptionCreationData,
116
  ): Promise<void> {
NEW
117
    return this.post(postData);
×
118
  }
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc