Class: Schematic::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: nil, max_retries: 2) ⇒ void

Parameters:

  • api_key (String)
  • base_url (String, nil) (defaults to: nil)
  • max_retries (Integer) (defaults to: 2)


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/schematic/client.rb', line 41

def initialize(api_key:, base_url: nil, max_retries: 2)
  @raw_client = Schematic::Internal::Http::RawClient.new(
    base_url: base_url || Schematic::Environment::DEFAULT,
    headers: {
      "User-Agent" => "schematichq/1.4.15",
      "X-Fern-Language" => "Ruby",
      "X-Schematic-Api-Key" => api_key.to_s
    },
    max_retries: max_retries
  )
end

Instance Method Details

#accesstokensSchematic::Accesstokens::Client



154
155
156
# File 'lib/schematic/client.rb', line 154

def accesstokens
  @accesstokens ||= Schematic::Accesstokens::Client.new(client: @raw_client)
end

#accountsSchematic::Accounts::Client



54
55
56
# File 'lib/schematic/client.rb', line 54

def accounts
  @accounts ||= Schematic::Accounts::Client.new(client: @raw_client)
end

#billingSchematic::Billing::Client



59
60
61
# File 'lib/schematic/client.rb', line 59

def billing
  @billing ||= Schematic::Billing::Client.new(client: @raw_client)
end

#catalogsSchematic::Catalogs::Client



69
70
71
# File 'lib/schematic/client.rb', line 69

def catalogs
  @catalogs ||= Schematic::Catalogs::Client.new(client: @raw_client)
end

#checkoutSchematic::Checkout::Client



74
75
76
# File 'lib/schematic/client.rb', line 74

def checkout
  @checkout ||= Schematic::Checkout::Client.new(client: @raw_client)
end

#companiesSchematic::Companies::Client



79
80
81
# File 'lib/schematic/client.rb', line 79

def companies
  @companies ||= Schematic::Companies::Client.new(client: @raw_client)
end

#componentsSchematic::Components::Client



94
95
96
# File 'lib/schematic/client.rb', line 94

def components
  @components ||= Schematic::Components::Client.new(client: @raw_client)
end

#componentspublicSchematic::Componentspublic::Client



144
145
146
# File 'lib/schematic/client.rb', line 144

def componentspublic
  @componentspublic ||= Schematic::Componentspublic::Client.new(client: @raw_client)
end

#creditsSchematic::Credits::Client



64
65
66
# File 'lib/schematic/client.rb', line 64

def credits
  @credits ||= Schematic::Credits::Client.new(client: @raw_client)
end

#dataexportsSchematic::Dataexports::Client



104
105
106
# File 'lib/schematic/client.rb', line 104

def dataexports
  @dataexports ||= Schematic::Dataexports::Client.new(client: @raw_client)
end

#entitlementsSchematic::Entitlements::Client



84
85
86
# File 'lib/schematic/client.rb', line 84

def entitlements
  @entitlements ||= Schematic::Entitlements::Client.new(client: @raw_client)
end

#eventsSchematic::Events::Client



109
110
111
# File 'lib/schematic/client.rb', line 109

def events
  @events ||= Schematic::Events::Client.new(client: @raw_client)
end

#featuresSchematic::Features::Client



114
115
116
# File 'lib/schematic/client.rb', line 114

def features
  @features ||= Schematic::Features::Client.new(client: @raw_client)
end

#get_credit_ledger(request_options: {}, **_params) ⇒ untyped

Examples:

client.get_credit_ledger

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:

  • (untyped)

Raises:

  • (error_class)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/schematic/client.rb', line 17

def get_credit_ledger(request_options: {}, **_params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "billing/credits/ledger",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#insightsSchematic::Insights::Client



119
120
121
# File 'lib/schematic/client.rb', line 119

def insights
  @insights ||= Schematic::Insights::Client.new(client: @raw_client)
end

#integrationsapiSchematic::Integrationsapi::Client



124
125
126
# File 'lib/schematic/client.rb', line 124

def integrationsapi
  @integrationsapi ||= Schematic::Integrationsapi::Client.new(client: @raw_client)
end

#licensesSchematic::Licenses::Client



129
130
131
# File 'lib/schematic/client.rb', line 129

def licenses
  @licenses ||= Schematic::Licenses::Client.new(client: @raw_client)
end

#planbundleSchematic::Planbundle::Client



99
100
101
# File 'lib/schematic/client.rb', line 99

def planbundle
  @planbundle ||= Schematic::Planbundle::Client.new(client: @raw_client)
end

#plangroupsSchematic::Plangroups::Client



134
135
136
# File 'lib/schematic/client.rb', line 134

def plangroups
  @plangroups ||= Schematic::Plangroups::Client.new(client: @raw_client)
end

#planmigrationsSchematic::Planmigrations::Client



139
140
141
# File 'lib/schematic/client.rb', line 139

def planmigrations
  @planmigrations ||= Schematic::Planmigrations::Client.new(client: @raw_client)
end

#plansSchematic::Plans::Client



89
90
91
# File 'lib/schematic/client.rb', line 89

def plans
  @plans ||= Schematic::Plans::Client.new(client: @raw_client)
end

#scheduledcheckoutSchematic::Scheduledcheckout::Client



149
150
151
# File 'lib/schematic/client.rb', line 149

def scheduledcheckout
  @scheduledcheckout ||= Schematic::Scheduledcheckout::Client.new(client: @raw_client)
end

#webhooksSchematic::Webhooks::Client



159
160
161
# File 'lib/schematic/client.rb', line 159

def webhooks
  @webhooks ||= Schematic::Webhooks::Client.new(client: @raw_client)
end