Sha256: b0a1edb25d7322f895c509a9edaab79a7215ca90b9b974950494ad2f75a4a254

Contents?: true

Size: 868 Bytes

Versions: 10

Compression:

Stored size: 868 Bytes

Contents

module Masheri
  class RestClient
    def build_url(query_params)
      Query.new(query_params).url
    end

    def activity(activity_type, service_id, options)
      if activity_type == "developer_activity"
        developer_activity(service_id, options)
      else
        raise "No such activity type!"
      end
    end

    def developer_activity_query(service_id, options)
      query_options = {service_id: service_id, resource: "developer_activity"}.merge(options)
      Query.new(query_options)
    end

    def developer_activity(service_id, options)
      query    = developer_activity_query(service_id, options)
      response = ::RestClient.get(query.url)

      if query.format == "json"
        JSON.parse(response)
      elsif query.format == "csv"
        response
      else
        raise UnknownFormat.new(query.format)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
masheri-0.6.0 lib/masheri/rest_client.rb
masheri-0.5.6 lib/masheri/rest_client.rb
masheri-0.5.5 lib/masheri/rest_client.rb
masheri-0.5.2 lib/masheri/rest_client.rb
masheri-0.5.1 lib/masheri/rest_client.rb
masheri-0.5.0 lib/masheri/rest_client.rb
masheri-0.4.0 lib/masheri/rest_client.rb
masheri-0.3.10 lib/masheri/rest_client.rb
masheri-0.3.8 lib/masheri/rest_client.rb
masheri-0.3.7 lib/masheri/rest_client.rb