Class: GrowsurfRuby::Resources::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/growsurf_ruby/resources/account.rb,
sig/growsurf_ruby/resources/account.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Account

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Account.

Parameters:



154
155
156
# File 'lib/growsurf_ruby/resources/account.rb', line 154

def initialize(client:)
  @client = client
end

Instance Method Details

#create(email:, company: nil, first_name: nil, last_name: nil, request_options: {}) ⇒ GrowsurfRuby::Models::AccountCreateResponse

Creates a new GrowSurf account. This is the only endpoint that does not require an API key. The response includes an API key for the new account, but the key is locked until the account's email address is verified: authenticated endpoints outside the Accounts group return a 403 with error code EMAIL_NOT_VERIFIED_ERROR until then (resend the email via POST /account/verification-email, then retry). A welcome email is sent to the address with the verification link and a set-password link for dashboard access. Accounts whose email is never verified are deleted automatically after 7 days. For security, the API key is rotated the first time the account owner signs in to the GrowSurf dashboard. Some actions (such as emailing participants) additionally require the GrowSurf team to verify the account first. By creating an account you agree, on behalf of the account holder, to GrowSurf's Terms of Service and Privacy Policy.

Parameters:

  • email (String)

    The email address for the new account. Personal emails and disposable email addresses are not accepted.

  • company (String)
  • first_name (String)
  • last_name (String)
  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
# File 'lib/growsurf_ruby/resources/account.rb', line 36

def create(params)
  parsed, options = GrowsurfRuby::AccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "accounts",
    body: parsed,
    model: GrowsurfRuby::Models::AccountCreateResponse,
    options: options
  )
end

#request_verification(request_options: {}) ⇒ GrowsurfRuby::Models::Account

Requests GrowSurf-team verification of your account (required before a program can email its participants). Idempotent — calling it again while a request is pending does not create a duplicate. Returns the account with its updated verificationStatus.

Parameters:

Returns:



123
124
125
126
127
128
129
130
# File 'lib/growsurf_ruby/resources/account.rb', line 123

def request_verification(params = {})
  @client.request(
    method: :post,
    path: "account/verification-request",
    model: GrowsurfRuby::Account,
    options: params[:request_options]
  )
end

#resend_verification_email(request_options: {}) ⇒ GrowsurfRuby::Models::AccountResendVerificationEmailResponse

Resends the email-verification email to the account's email address. A 200 with status: SENT is only returned when an email was actually dispatched. Returns a 400 if the email is already verified, or a 429 if a verification email was sent too recently — wait a moment, then retry.

Parameters:

Returns:



142
143
144
145
146
147
148
149
# File 'lib/growsurf_ruby/resources/account.rb', line 142

def resend_verification_email(params = {})
  @client.request(
    method: :post,
    path: "account/verification-email",
    model: GrowsurfRuby::Models::AccountResendVerificationEmailResponse,
    options: params[:request_options]
  )
end

#retrieve(request_options: {}) ⇒ GrowsurfRuby::Models::Account

Retrieves the account that owns the API key: profile and GrowSurf-team verification state. verificationStatus is VERIFIED once the GrowSurf team has verified the account — this is required before you can send participant emails from a program.

Parameters:

Returns:



57
58
59
60
61
62
63
64
# File 'lib/growsurf_ruby/resources/account.rb', line 57

def retrieve(params = {})
  @client.request(
    method: :get,
    path: "account",
    model: GrowsurfRuby::Account,
    options: params[:request_options]
  )
end

#rotate_api_key(request_options: {}) ⇒ GrowsurfRuby::Models::AccountRotateAPIKeyResponse

Generates a new API key and immediately revokes the old one. The key used to make this request stops working as soon as the response is returned — update every integration that used the old key with the new one. The account owner is notified by email whenever the key is rotated.

Parameters:

Returns:



104
105
106
107
108
109
110
111
# File 'lib/growsurf_ruby/resources/account.rb', line 104

def rotate_api_key(params = {})
  @client.request(
    method: :post,
    path: "account/api-key",
    model: GrowsurfRuby::Models::AccountRotateAPIKeyResponse,
    options: params[:request_options]
  )
end

#update(company: nil, first_name: nil, last_name: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Account

Updates your own account profile (firstName, lastName, company). Any other property is rejected with a 400 — in particular, the account email cannot be changed via the API, and billing/subscription is not editable here.

Parameters:

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
# File 'lib/growsurf_ruby/resources/account.rb', line 83

def update(params = {})
  parsed, options = GrowsurfRuby::AccountUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: "account",
    body: parsed,
    model: GrowsurfRuby::Account,
    options: options
  )
end