Sha256: 9e9db9c2c0c717c5ac00a726fc7acdb956f921824ffd6688ab68493d93626a56
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Jiminy module Reporting module CIProviders module CircleCI require_relative "api_request" class Base require "uri" require "net/http" require "json" attr_reader :attributes def self.define_attribute_readers(*attr_names) attr_names.each do |attr_name| define_method(attr_name, -> { attributes[__callee__.to_s] }) end end class << self attr_reader :next_token end class << self attr_writer :next_token end def self.fetch_api_resource(path) response = APIRequest.new(path).perform! raise "Error response: #{response.body}" unless response.is_a?(Net::HTTPOK) json_body = JSON.parse(response.read_body) self.next_token = json_body["next_page_token"] json_body["items"].map { |attributes| new(attributes) } end def initialize(attributes = {}) @attributes = attributes.transform_keys!(&:to_s) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems