Class: Pingram::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pingram/client_wrapper.rb

Overview

High-level Pingram client: holds API key and base URL, exposes tag APIs and send.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • api_key (String)

    API key (e.g. pingram_sk_…) or JWT

  • base_url (String, nil) (defaults to: nil)

    Optional override for base URL (e.g. api.pingram.io)



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/pingram/client_wrapper.rb', line 62

def initialize(api_key:, base_url: nil)
  @api_key = api_key
  @base_url = base_url
  @config = Pingram::Configuration.default.dup
  @config.access_token = api_key
  @config.host = base_url.to_s.sub(%r{/$}, '') if base_url && !base_url.to_s.empty?
  @api_client = Pingram::ApiClient.new(@config)

  @account = Pingram::AccountApi.new(@api_client)

  @addresses = Pingram::AddressesApi.new(@api_client)

  @components = Pingram::ComponentsApi.new(@api_client)

  @default_api = Pingram::DefaultApi.new(@api_client)

  @domains = Pingram::DomainsApi.new(@api_client)

  @editor = Pingram::EditorApi.new(@api_client)

  @environments = Pingram::EnvironmentsApi.new(@api_client)

  @health = Pingram::HealthApi.new(@api_client)

  @insights = Pingram::InsightsApi.new(@api_client)

  @keys = Pingram::KeysApi.new(@api_client)

  @logs = Pingram::LogsApi.new(@api_client)

  @members = Pingram::MembersApi.new(@api_client)

  @organization = Pingram::OrganizationApi.new(@api_client)

  @push_settings = Pingram::PushsettingsApi.new(@api_client)

  @sender = Pingram::SenderApi.new(@api_client)

  @templates = Pingram::TemplatesApi.new(@api_client)

  @types = Pingram::TypesApi.new(@api_client)

  @user = Pingram::UserApi.new(@api_client)

  @users = Pingram::UsersApi.new(@api_client)

  @webhooks = Pingram::WebhooksApi.new(@api_client)

end

Instance Attribute Details

#api_keyString (readonly)

Returns API key (e.g. pingram_sk_…).

Returns:

  • (String)

    API key (e.g. pingram_sk_…)



55
56
57
# File 'lib/pingram/client_wrapper.rb', line 55

def api_key
  @api_key
end

#base_urlString? (readonly)

Returns Override base URL (default from Configuration).

Returns:

  • (String, nil)

    Override base URL (default from Configuration)



58
59
60
# File 'lib/pingram/client_wrapper.rb', line 58

def base_url
  @base_url
end

Instance Method Details

#accountPingram::AccountApi

Returns:



114
115
116
# File 'lib/pingram/client_wrapper.rb', line 114

def 
  @account
end

#addressesPingram::AddressesApi



120
121
122
# File 'lib/pingram/client_wrapper.rb', line 120

def addresses
  @addresses
end

#componentsPingram::ComponentsApi



126
127
128
# File 'lib/pingram/client_wrapper.rb', line 126

def components
  @components
end

#default_apiPingram::DefaultApi

Returns:



132
133
134
# File 'lib/pingram/client_wrapper.rb', line 132

def default_api
  @default_api
end

#domainsPingram::DomainsApi

Returns:



138
139
140
# File 'lib/pingram/client_wrapper.rb', line 138

def domains
  @domains
end

#editorPingram::EditorApi

Returns:



144
145
146
# File 'lib/pingram/client_wrapper.rb', line 144

def editor
  @editor
end

#environmentsPingram::EnvironmentsApi



150
151
152
# File 'lib/pingram/client_wrapper.rb', line 150

def environments
  @environments
end

#healthPingram::HealthApi

Returns:



156
157
158
# File 'lib/pingram/client_wrapper.rb', line 156

def health
  @health
end

#insightsPingram::InsightsApi



162
163
164
# File 'lib/pingram/client_wrapper.rb', line 162

def insights
  @insights
end

#keysPingram::KeysApi

Returns:



168
169
170
# File 'lib/pingram/client_wrapper.rb', line 168

def keys
  @keys
end

#logsPingram::LogsApi

Returns:



174
175
176
# File 'lib/pingram/client_wrapper.rb', line 174

def logs
  @logs
end

#membersPingram::MembersApi

Returns:



180
181
182
# File 'lib/pingram/client_wrapper.rb', line 180

def members
  @members
end

#organizationPingram::OrganizationApi



186
187
188
# File 'lib/pingram/client_wrapper.rb', line 186

def organization
  @organization
end

#push_settingsPingram::PushsettingsApi

Returns:

  • (Pingram::PushsettingsApi)


192
193
194
# File 'lib/pingram/client_wrapper.rb', line 192

def push_settings
  @push_settings
end

#send(body) ⇒ Object

Send a notification. Delegates to DefaultApi#call_send (Ruby renames send to call_send).

Parameters:

  • body (Object)

    Request body (e.g. Pingram::SenderPostBody or Hash)

Returns:

  • (Object)

    Response (e.g. Pingram::SenderPostResponse)



237
238
239
# File 'lib/pingram/client_wrapper.rb', line 237

def send(body)
  @default_api.call_send(body)
end

#senderPingram::SenderApi

Returns:



198
199
200
# File 'lib/pingram/client_wrapper.rb', line 198

def sender
  @sender
end

#templatesPingram::TemplatesApi



204
205
206
# File 'lib/pingram/client_wrapper.rb', line 204

def templates
  @templates
end

#typesPingram::TypesApi

Returns:



210
211
212
# File 'lib/pingram/client_wrapper.rb', line 210

def types
  @types
end

#userPingram::UserApi

Returns:



216
217
218
# File 'lib/pingram/client_wrapper.rb', line 216

def user
  @user
end

#usersPingram::UsersApi

Returns:



222
223
224
# File 'lib/pingram/client_wrapper.rb', line 222

def users
  @users
end

#webhooksPingram::WebhooksApi



228
229
230
# File 'lib/pingram/client_wrapper.rb', line 228

def webhooks
  @webhooks
end