Class: LockstepSdk::LockstepApi
- Inherits:
-
Object
- Object
- LockstepSdk::LockstepApi
- Defined in:
- lib/lockstep_sdk/lockstep_api.rb
Instance Attribute Summary collapse
-
#activities ⇒ ActivitiesClient
Client object for Activities endpoints.
-
#api_keys ⇒ ApiKeysClient
Client object for ApiKeys endpoints.
-
#app_enrollments ⇒ AppEnrollmentsClient
Client object for AppEnrollments endpoints.
-
#applications ⇒ ApplicationsClient
Client object for Applications endpoints.
-
#attachments ⇒ AttachmentsClient
Client object for Attachments endpoints.
-
#code_definitions ⇒ CodeDefinitionsClient
Client object for CodeDefinitions endpoints.
-
#companies ⇒ CompaniesClient
Client object for Companies endpoints.
-
#contacts ⇒ ContactsClient
Client object for Contacts endpoints.
-
#credit_memo_applied ⇒ CreditMemoAppliedClient
Client object for CreditMemoApplied endpoints.
-
#currencies ⇒ CurrenciesClient
Client object for Currencies endpoints.
-
#custom_field_definitions ⇒ CustomFieldDefinitionsClient
Client object for CustomFieldDefinitions endpoints.
-
#custom_field_values ⇒ CustomFieldValuesClient
Client object for CustomFieldValues endpoints.
-
#definitions ⇒ DefinitionsClient
Client object for Definitions endpoints.
-
#emails ⇒ EmailsClient
Client object for Emails endpoints.
-
#env ⇒ String
The name or URL of the environment.
-
#invoice_history ⇒ InvoiceHistoryClient
Client object for InvoiceHistory endpoints.
-
#invoices ⇒ InvoicesClient
Client object for Invoices endpoints.
-
#leads ⇒ LeadsClient
Client object for Leads endpoints.
-
#notes ⇒ NotesClient
Client object for Notes endpoints.
-
#payment_applications ⇒ PaymentApplicationsClient
Client object for PaymentApplications endpoints.
-
#payments ⇒ PaymentsClient
Client object for Payments endpoints.
-
#provisioning ⇒ ProvisioningClient
Client object for Provisioning endpoints.
-
#reports ⇒ ReportsClient
Client object for Reports endpoints.
-
#status ⇒ StatusClient
Client object for Status endpoints.
-
#sync ⇒ SyncClient
Client object for Sync endpoints.
-
#user_accounts ⇒ UserAccountsClient
Client object for UserAccounts endpoints.
-
#user_roles ⇒ UserRolesClient
Client object for UserRoles endpoints.
-
#version ⇒ String
The version number of this Lockstep API client.
Instance Method Summary collapse
-
#initialize(env) ⇒ LockstepApi
constructor
Construct a new Lockstep API client targeting the specified server.
-
#request(method, path, body, params) ⇒ Object
Send a request to the API and return the results.
-
#with_api_key(api_key) ⇒ Object
Configure this API client to use API key authentication.
-
#with_app_name(app_name) ⇒ Object
Configure this API to use an application name.
-
#with_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication.
Constructor Details
#initialize(env) ⇒ LockstepApi
Construct a new Lockstep API client targeting the specified server.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 145 def initialize(env) @version = "2022.4.32.0" @env = case env when "sbx" "https://api.sbx.lockstep.io/" when "prd" "https://api.lockstep.io/" else env end # Construct all the clients @activities = ActivitiesClient.new(self) @api_keys = ApiKeysClient.new(self) @app_enrollments = AppEnrollmentsClient.new(self) @applications = ApplicationsClient.new(self) @attachments = AttachmentsClient.new(self) @code_definitions = CodeDefinitionsClient.new(self) @companies = CompaniesClient.new(self) @contacts = ContactsClient.new(self) @credit_memo_applied = CreditMemoAppliedClient.new(self) @currencies = CurrenciesClient.new(self) @custom_field_definitions = CustomFieldDefinitionsClient.new(self) @custom_field_values = CustomFieldValuesClient.new(self) @definitions = DefinitionsClient.new(self) @emails = EmailsClient.new(self) @invoice_history = InvoiceHistoryClient.new(self) @invoices = InvoicesClient.new(self) @leads = LeadsClient.new(self) @notes = NotesClient.new(self) @payment_applications = PaymentApplicationsClient.new(self) @payments = PaymentsClient.new(self) @provisioning = ProvisioningClient.new(self) @reports = ReportsClient.new(self) @status = StatusClient.new(self) @sync = SyncClient.new(self) @user_accounts = UserAccountsClient.new(self) @user_roles = UserRolesClient.new(self) end |
Instance Attribute Details
#activities ⇒ ActivitiesClient
Returns Client object for Activities endpoints.
38 39 40 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 38 def activities @activities end |
#api_keys ⇒ ApiKeysClient
Returns Client object for ApiKeys endpoints.
42 43 44 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 42 def api_keys @api_keys end |
#app_enrollments ⇒ AppEnrollmentsClient
Returns Client object for AppEnrollments endpoints.
46 47 48 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 46 def app_enrollments @app_enrollments end |
#applications ⇒ ApplicationsClient
Returns Client object for Applications endpoints.
50 51 52 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 50 def applications @applications end |
#attachments ⇒ AttachmentsClient
Returns Client object for Attachments endpoints.
54 55 56 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 54 def @attachments end |
#code_definitions ⇒ CodeDefinitionsClient
Returns Client object for CodeDefinitions endpoints.
58 59 60 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 58 def code_definitions @code_definitions end |
#companies ⇒ CompaniesClient
Returns Client object for Companies endpoints.
62 63 64 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 62 def companies @companies end |
#contacts ⇒ ContactsClient
Returns Client object for Contacts endpoints.
66 67 68 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 66 def contacts @contacts end |
#credit_memo_applied ⇒ CreditMemoAppliedClient
Returns Client object for CreditMemoApplied endpoints.
70 71 72 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 70 def credit_memo_applied @credit_memo_applied end |
#currencies ⇒ CurrenciesClient
Returns Client object for Currencies endpoints.
74 75 76 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 74 def currencies @currencies end |
#custom_field_definitions ⇒ CustomFieldDefinitionsClient
Returns Client object for CustomFieldDefinitions endpoints.
78 79 80 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 78 def custom_field_definitions @custom_field_definitions end |
#custom_field_values ⇒ CustomFieldValuesClient
Returns Client object for CustomFieldValues endpoints.
82 83 84 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 82 def custom_field_values @custom_field_values end |
#definitions ⇒ DefinitionsClient
Returns Client object for Definitions endpoints.
86 87 88 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 86 def definitions @definitions end |
#emails ⇒ EmailsClient
Returns Client object for Emails endpoints.
90 91 92 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 90 def emails @emails end |
#env ⇒ String
Returns The name or URL of the environment.
34 35 36 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 34 def env @env end |
#invoice_history ⇒ InvoiceHistoryClient
Returns Client object for InvoiceHistory endpoints.
94 95 96 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 94 def invoice_history @invoice_history end |
#invoices ⇒ InvoicesClient
Returns Client object for Invoices endpoints.
98 99 100 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 98 def invoices @invoices end |
#leads ⇒ LeadsClient
Returns Client object for Leads endpoints.
102 103 104 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 102 def leads @leads end |
#notes ⇒ NotesClient
Returns Client object for Notes endpoints.
106 107 108 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 106 def notes @notes end |
#payment_applications ⇒ PaymentApplicationsClient
Returns Client object for PaymentApplications endpoints.
110 111 112 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 110 def payment_applications @payment_applications end |
#payments ⇒ PaymentsClient
Returns Client object for Payments endpoints.
114 115 116 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 114 def payments @payments end |
#provisioning ⇒ ProvisioningClient
Returns Client object for Provisioning endpoints.
118 119 120 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 118 def provisioning @provisioning end |
#reports ⇒ ReportsClient
Returns Client object for Reports endpoints.
122 123 124 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 122 def reports @reports end |
#status ⇒ StatusClient
Returns Client object for Status endpoints.
126 127 128 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 126 def status @status end |
#sync ⇒ SyncClient
Returns Client object for Sync endpoints.
130 131 132 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 130 def sync @sync end |
#user_accounts ⇒ UserAccountsClient
Returns Client object for UserAccounts endpoints.
134 135 136 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 134 def user_accounts @user_accounts end |
#user_roles ⇒ UserRolesClient
Returns Client object for UserRoles endpoints.
138 139 140 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 138 def user_roles @user_roles end |
#version ⇒ String
Returns The version number of this Lockstep API client.
30 31 32 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 30 def version @version end |
Instance Method Details
#request(method, path, body, params) ⇒ Object
Send a request to the API and return the results
Sends a request to the
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 215 def request(method, path, body, params) url = URI(@env + path) if !params.nil? url.query = URI.encode_www_form(params) end http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = case method when :get Net::HTTP::Get.new(url) when :post Net::HTTP::Post.new(url) when :patch Net::HTTP::Patch.new(url) when :put Net::HTTP::Put.new(url) when :delete Net::HTTP::Delete.new(url) end # Set headers and body for request request["Accept"] = 'application/json' request["Content-Type"] = 'application/*+json' request["SdkType"] = 'Ruby' request["SdkVersion"] = '2022.4.32.0' request["MachineName"] = Socket.gethostname request.body = body # If there is an application name if @app_name != nil request["ApplicationName"] = @app_name end # Which authentication are we using? if @api_key != nil request["Api-Key"] = @api_key end if @bearer_token != nil request["Authorization"] = 'Bearer ' + @bearer_token end # Send the request response = http.request(request) response.read_body end |
#with_api_key(api_key) ⇒ Object
Configure this API client to use API key authentication
189 190 191 192 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 189 def with_api_key(api_key) @bearer_token = nil @api_key = api_key end |
#with_app_name(app_name) ⇒ Object
Configure this API to use an application name
207 208 209 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 207 def with_app_name(app_name) @app_name = app_name end |
#with_bearer_token(bearer_token) ⇒ Object
Configure this API client to use JWT Bearer Token authentication
198 199 200 201 |
# File 'lib/lockstep_sdk/lockstep_api.rb', line 198 def with_bearer_token(bearer_token) @api_key = nil @bearer_token = bearer_token end |