module Ecoportal module API # @attr_reader client [Common::GraphQL::Client] a client object that holds the configuration of the api connection. # @attr_reader logger [Logger] the logger. class GraphQL include Ecoportal::API::Common::GraphQL::ClassHelpers attr_reader :client, :fragments # Creates a `GraphQL` object to interact with the ecoPortal `GraphQL API`. # @param org_id [String] the id of the target organization. # It defaults to the environmental variable `ORGANIZATION_ID`, if defined # @param logger [Logger] an object with `Logger` interface to generate logs. def initialize(email: nil, pass: nil, org_id: nil, host: "live.ecoportal.com") kargs = {email: email, pass: pass, host: host, org_id: org_id, no_schema: true} @client = Ecoportal::API::Common::GraphQL::Client.new(**kargs) @fragments = Ecoportal::API::GraphQL::Fragment.new(client) end def currentOrganizationClass API::GraphQL::Model::Organization.tap do |org_class| org_class.client = client end end def currentOrganization currentOrganizationClass end def createContractorEntity(input:, &block) createContractorEntityMutation.query(input: input, &block) end def contractorEntity Ecoportal::API::GraphQL::Builder::ContractorEntity.new(client) end # Gives a builder to use different options to modify a reporting structure def locationStructure Ecoportal::API::GraphQL::Builder::LocationStructure.new(client) end # Gives a builder to use different options to play with action def action Ecoportal::API::GraphQL::Builder::Action.new(client) end private def createContractorEntityMutation Ecoportal::API::GraphQL::Mutation::ContractorEntity::Create.new(client) end end end end require 'ecoportal/api/graphql/helpers' require 'ecoportal/api/graphql/base' require 'ecoportal/api/graphql/model' require 'ecoportal/api/graphql/error' require 'ecoportal/api/graphql/logic' require 'ecoportal/api/graphql/connection' require 'ecoportal/api/graphql/payload' require 'ecoportal/api/graphql/input' require 'ecoportal/api/graphql/fragment' require 'ecoportal/api/graphql/query' require 'ecoportal/api/graphql/mutation' require 'ecoportal/api/graphql/builder'