Class: NewDemoApiClient::DealClient

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/deal/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ NewDemoApiClient::DealClient

Parameters:



18
19
20
# File 'lib/test_sdk/deal/client.rb', line 18

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientNewDemoApiClient::RequestClient (readonly)



14
15
16
# File 'lib/test_sdk/deal/client.rb', line 14

def request_client
  @request_client
end

Instance Method Details

#create(group_id:, name:, round_name:, status:, company_id:, notes: nil, priority: nil, round_amount: nil, round_target: nil, tags: nil, request_options: nil) ⇒ NewDemoApiClient::DealWithFilesResponse

Create a new deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.create(
  group_id: 1,
  name: "name",
  round_name: "round_name",
  status: QUEUED,
  company_id: 1
)

Parameters:

  • group_id (Integer)
  • name (String)
  • round_name (String)

    The name of the round

  • status (NewDemoApiClient::Status)

    The status of the deal

  • notes (String) (defaults to: nil)

    Notes about the deal

  • priority (NewDemoApiClient::Priority) (defaults to: nil)

    The priority of the deal

  • round_amount (Integer) (defaults to: nil)

    The dollar amount to be raised of the round

  • round_target (Integer) (defaults to: nil)

    The target post-money dollar amount of the round

  • tags (Array<String>) (defaults to: nil)

    The tags associated with the deal

  • company_id (Integer)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/test_sdk/deal/client.rb', line 49

def create(group_id:, name:, round_name:, status:, company_id:, notes: nil, priority: nil, round_amount: nil, round_target: nil,
           tags: nil, request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      name: name,
      round_name: round_name,
      status: status,
      notes: notes,
      priority: priority,
      round_amount: round_amount,
      round_target: round_target,
      tags: tags,
      company_id: company_id
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal"
  end
  NewDemoApiClient::DealWithFilesResponse.from_json(json_object: response.body)
end

#delete(deal_id:, group_id:, archive: nil, request_options: nil) ⇒ Hash{String => String}

Delete a deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.delete(deal_id: 1, group_id: 1)

Parameters:

Returns:

  • (Hash{String => String})


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/test_sdk/deal/client.rb', line 273

def delete(deal_id:, group_id:, archive: nil, request_options: nil)
  response = @request_client.conn.delete do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = { **(request_options&.additional_query_parameters || {}), "archive": archive }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{deal_id}/deal/#{group_id}"
  end
  JSON.parse(response.body)
end

#get(group_id:, deal_id:, request_options: nil) ⇒ NewDemoApiClient::DealWithFilesResponse

Retrieve a deal by its ID.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.get(group_id: 1, deal_id: 1)

Parameters:

Returns:



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/test_sdk/deal/client.rb', line 187

def get(group_id:, deal_id:, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}"
  end
  NewDemoApiClient::DealWithFilesResponse.from_json(json_object: response.body)
end

#list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseDealWithFilesResponse

Get all deals for a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.list(group_id: 1)

Parameters:

  • group_id (Integer)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/test_sdk/deal/client.rb', line 95

def list(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "sort_by": sort_by,
      "sort_order": sort_order,
      "page": page,
      "page_size": page_size
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/all"
  end
  NewDemoApiClient::PaginatedResponseDealWithFilesResponse.from_json(json_object: response.body)
end

#search(group_id:, name: nil, round_name: nil, notes: nil, tags: nil, company_name: nil, company_domain: nil, ignore_archived: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseDealWithFilesResponse

Search deals within a group.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.search(group_id: 1)

Parameters:

  • group_id (Integer)
  • name (String) (defaults to: nil)
  • round_name (String) (defaults to: nil)
  • notes (String) (defaults to: nil)
  • tags (String) (defaults to: nil)
  • company_name (String) (defaults to: nil)
  • company_domain (String) (defaults to: nil)
  • ignore_archived (Boolean) (defaults to: nil)
  • sort_by (String) (defaults to: nil)
  • sort_order (String) (defaults to: nil)
  • page (Integer) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/test_sdk/deal/client.rb', line 142

def search(group_id:, name: nil, round_name: nil, notes: nil, tags: nil, company_name: nil, company_domain: nil,
           ignore_archived: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "name": name,
      "round_name": round_name,
      "notes": notes,
      "tags": tags,
      "company_name": company_name,
      "company_domain": company_domain,
      "ignore_archived": ignore_archived,
      "sort_by": sort_by,
      "sort_order": sort_order,
      "page": page,
      "page_size": page_size
    }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/search"
  end
  NewDemoApiClient::PaginatedResponseDealWithFilesResponse.from_json(json_object: response.body)
end

#update(group_id:, deal_id:, name: nil, round_name: nil, status: nil, notes: nil, priority: nil, round_amount: nil, round_target: nil, tags: nil, company_id: nil, request_options: nil) ⇒ NewDemoApiClient::DealWithFilesResponse

Update a deal.

Examples:

api = NewDemoApiClient::Client.new(
  base_url: "https://api.example.com",
  environment: NewDemoApiClient::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.deal.update(group_id: 1, deal_id: 1)

Parameters:

  • group_id (Integer)
  • deal_id (Integer)
  • name (String) (defaults to: nil)
  • round_name (String) (defaults to: nil)
  • status (NewDemoApiClient::Status) (defaults to: nil)
  • notes (String) (defaults to: nil)

    Notes about the deal

  • priority (NewDemoApiClient::Priority) (defaults to: nil)

    The priority of the deal

  • round_amount (Integer) (defaults to: nil)

    The dollar amount to be raised of the round

  • round_target (Integer) (defaults to: nil)

    The target post-money dollar amount of the round

  • tags (Array<String>) (defaults to: nil)

    The tags associated with the deal

  • company_id (Integer) (defaults to: nil)
  • request_options (NewDemoApiClient::RequestOptions) (defaults to: nil)

Returns:



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/test_sdk/deal/client.rb', line 229

def update(group_id:, deal_id:, name: nil, round_name: nil, status: nil, notes: nil, priority: nil,
           round_amount: nil, round_target: nil, tags: nil, company_id: nil, request_options: nil)
  response = @request_client.conn.put do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    unless request_options.nil? || request_options&.additional_query_parameters.nil?
      req.params = { **(request_options&.additional_query_parameters || {}) }.compact
    end
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      name: name,
      round_name: round_name,
      status: status,
      notes: notes,
      priority: priority,
      round_amount: round_amount,
      round_target: round_target,
      tags: tags,
      company_id: company_id
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/api/v1/group/#{group_id}/deal/#{deal_id}"
  end
  NewDemoApiClient::DealWithFilesResponse.from_json(json_object: response.body)
end