Sha256: 08065f627705491119307ce157dd79bbd892dfedb91520ad5205dfd165d5e560

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

require_relative "model.rb"
module Figo
  # Retrieve the URL a user should open in the web browser to start the synchronization process.
  #
  # @param redirect_uri [String] The user will be redirected to this URL after the sync process completes.
  # @param state [String] This string will be passed on through the complete synchronization process
  # @return [String] The result parameter is the URL to be opened by the user.
  def get_sync_url(redirect_uri, state)
    res = query_api "/rest/sync", {redirect_uri: redirect_uri, state: state}.to_query, "POST"

    "https://" + Config.api_endpoint + "/task/start?id=" + res["task_token"]
  end

  # Retrieve the URL a user should open in the web browser to start the synchronization process.
  #
  # @param redirect_uri [String] the user will be redirected to this URL after the process completes
  # @param state [String] this string will be passed on through the complete synchronization process
  #        and to the redirect target at the end. It should be used to validated the authenticity of
  #        the call to the redirect URL
  # @param if_not_synced_since [Integer] if this parameter is set, only those accounts will be
  #        synchronized, which have not been synchronized within the specified number of minutes.
  # @return [String] the URL to be opened by the user.
  def sync_url(redirect_uri, state, if_not_synced_since = 0)
    response = query_api "/rest/sync", {"redirect_uri" => redirect_uri, "state" => state, "if_not_synced_since" => if_not_synced_since}, "POST"
    return "https://#{$api_endpoint}/task/start?id=#{response["task_token"]}"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
figo-1.4.2 lib/synchronization_status/api_call.rb
figo-1.4.1 lib/synchronization_status/api_call.rb
figo-1.4.0 lib/synchronization_status/api_call.rb
figo-1.3.3 lib/synchronization_status/api_call.rb