Sha256: e24083f179d140f409485e06c0862860a420171c2e39a0d7e16d3a605c5b60f5

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module TokyoApi
  class Campact < Base
    def base_path
      'campact'
    end

    def full_user(session_id)
      client.get_request("#{normalized_base_path}full_user/#{url_escape(session_id)}").body
    end

    def session_status(session_id)
      client.get_request("/#{normalized_base_path}session/#{url_escape(session_id)}/status").body
    end

    def destroy_session(session_id)
      client.delete_request("/#{normalized_base_path}session/#{url_escape(session_id)}").status == 204
    end

    def subscription_status(token)
      client.get_request(subscription_status_path(token)).body
    rescue Vertebrae::ResponseError => e
      # Status 404 is expected in these calls
      return nil if e.status_code == 404

      raise
    end

    def user_path(session_id, petition_id:, with_subscription_status: false, required_fields: nil)
      path = String.new("/#{normalized_base_path}user/#{url_escape(session_id)}?petition_id=#{url_escape(petition_id)}")
      path << '&with_subscription_status=true' if with_subscription_status
      path << "&#{required_fields_param(required_fields)}" unless required_fields.nil?
      path
    end

    def subscription_status_path(token)
      "/#{normalized_base_path}subscription_status/#{url_escape(token)}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tokyo_api-1.9.0 lib/tokyo_api/campact.rb
tokyo_api-1.8.0 lib/tokyo_api/campact.rb
tokyo_api-1.7.0 lib/tokyo_api/campact.rb
tokyo_api-1.6.0 lib/tokyo_api/campact.rb