Sha256: f903ed47d6cd2fe8b6dde0ae86f88d7f55a03637eaf66eb89bfd2540f1c80b2c

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

module TokyoApi
  class Krautbuster < Base
    def base_path
      'krautbuster'
    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_status/#{url_escape(session_id)}").body
    end

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

        raise
      end
    end

    def user_path(session_id, petition_id:, with_subscription_status: false, required_fields: nil)
      path = "/#{normalized_base_path}user/#{url_escape(session_id)}?petition_id=#{url_escape(petition_id)}"
      if with_subscription_status
        path << '&with_subscription_status=true'
      end
      unless required_fields.nil?
        path << "&#{required_fields_param(required_fields)}"
      end
      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.3.1 lib/tokyo_api/krautbuster.rb
tokyo_api-1.3.0 lib/tokyo_api/krautbuster.rb
tokyo_api-1.2.0 lib/tokyo_api/krautbuster.rb
tokyo_api-1.1.2 lib/tokyo_api/krautbuster.rb