Class: Merge::Filestorage::LinkTokenClient

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/filestorage/link_token/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Merge::Filestorage::LinkTokenClient

Parameters:



17
18
19
# File 'lib/merge_ruby_client/filestorage/link_token/client.rb', line 17

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientMerge::RequestClient (readonly)



13
14
15
# File 'lib/merge_ruby_client/filestorage/link_token/client.rb', line 13

def request_client
  @request_client
end

Instance Method Details

#create(end_user_email_address:, end_user_organization_name:, end_user_origin_id:, categories:, integration: nil, link_expiry_mins: nil, should_create_magic_link_url: nil, hide_admin_magic_link: nil, common_models: nil, category_common_model_scopes: nil, language: nil, integration_specific_config: nil, request_options: nil) ⇒ Merge::Filestorage::LinkToken

Creates a link token to be used when linking a new end user.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.filestorage.link_token.create(
  end_user_email_address: "[email protected]",
  end_user_organization_name: "Test Organization",
  end_user_origin_id: "12345",
  categories: [HRIS, ATS]
)

Parameters:

  • end_user_email_address (String)

    Your end user’s email address. This is purely for identification purposes - setting this value will not cause any emails to be sent.

  • end_user_organization_name (String)

    Your end user’s organization.

  • end_user_origin_id (String)

    This unique identifier typically represents the ID for your end user in your product’s database. This value must be distinct from other Linked Accounts’ unique identifiers.

  • categories (Array<Merge::Filestorage::CategoriesEnum>)

    The integration categories to show in Merge Link.

  • integration (String) (defaults to: nil)

    The slug of a specific pre-selected integration for this linking flow token. For examples of slugs, see docs.merge.dev/guides/merge-link/single-integration/.

  • link_expiry_mins (Integer) (defaults to: nil)

    An integer number of minutes between [30, 720 or 10080 if for a Magic Link URL] for how long this token is valid. Defaults to 30.

  • should_create_magic_link_url (Boolean) (defaults to: nil)

    Whether to generate a Magic Link URL. Defaults to false. For more information on Magic Link, see merge.dev/blog/integrations-fast-say-hello-to-magic-link.

  • hide_admin_magic_link (Boolean) (defaults to: nil)

    Whether to generate a Magic Link URL on the Admin Needed screen during the linking flow. Defaults to false. For more information on Magic Link, see merge.dev/blog/integrations-fast-say-hello-to-magic-link.

  • common_models (Array<Hash>) (defaults to: nil)

    An array of objects to specify the models and fields that will be disabled for a given Linked Account. Each object uses model_id, enabled_actions, and disabled_fields to specify the model, method, and fields that are scoped for a given Linked Account.Request of type Array<Merge::Filestorage::CommonModelScopesBodyRequest>, as a Hash

    * :model_id (String)
    * :enabled_actions (Array<Merge::Filestorage::EnabledActionsEnum>)
    * :disabled_fields (Array<String>)
    
  • category_common_model_scopes (Hash{String => Array}) (defaults to: nil)

    When creating a Link Token, you can set permissions for Common Models that will apply to the account that is going to be linked. Any model or field not specified in link token payload will default to existing settings.

  • language (String) (defaults to: nil)

    The language code for the language to localize Merge Link to.

  • integration_specific_config (Hash{String => Object}) (defaults to: nil)

    A JSON object containing integration-specific configuration options.

  • request_options (Merge::RequestOptions) (defaults to: nil)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/merge_ruby_client/filestorage/link_token/client.rb', line 67

def create(end_user_email_address:, end_user_organization_name:, end_user_origin_id:, categories:,
           integration: nil, link_expiry_mins: nil, should_create_magic_link_url: nil, hide_admin_magic_link: nil, common_models: nil, category_common_model_scopes: nil, language: nil, integration_specific_config: 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.api_key unless request_options&.api_key.nil?
    req.headers["X-Account-Token"] = request_options. unless request_options&..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 || {}),
      end_user_email_address: end_user_email_address,
      end_user_organization_name: end_user_organization_name,
      end_user_origin_id: end_user_origin_id,
      categories: categories,
      integration: integration,
      link_expiry_mins: link_expiry_mins,
      should_create_magic_link_url: should_create_magic_link_url,
      hide_admin_magic_link: hide_admin_magic_link,
      common_models: common_models,
      category_common_model_scopes: category_common_model_scopes,
      language: language,
      integration_specific_config: integration_specific_config
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/filestorage/v1/link-token"
  end
  Merge::Filestorage::LinkToken.from_json(json_object: response.body)
end