Class: LockstepSdk::LockstepApi

Inherits:
Object
  • Object
show all
Defined in:
lib/lockstep_sdk/lockstep_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ LockstepApi

Construct a new Lockstep API client targeting the specified server.

Parameters:

  • env (string)

    Either “sbx”, “prd”, or the URI of the server, ending in a slash (/)



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/lockstep_sdk/lockstep_api.rb', line 87

def initialize(env)
    @version = "2022.3.50.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

#activitiesActivitiesClient

Returns Client object for Activities endpoints.

Returns:



32
33
34
# File 'lib/lockstep_sdk/lockstep_api.rb', line 32

def activities
  @activities
end

#api_keysApiKeysClient

Returns Client object for ApiKeys endpoints.

Returns:



34
35
36
# File 'lib/lockstep_sdk/lockstep_api.rb', line 34

def api_keys
  @api_keys
end

#app_enrollmentsAppEnrollmentsClient

Returns Client object for AppEnrollments endpoints.

Returns:



36
37
38
# File 'lib/lockstep_sdk/lockstep_api.rb', line 36

def app_enrollments
  @app_enrollments
end

#applicationsApplicationsClient

Returns Client object for Applications endpoints.

Returns:



38
39
40
# File 'lib/lockstep_sdk/lockstep_api.rb', line 38

def applications
  @applications
end

#attachmentsAttachmentsClient

Returns Client object for Attachments endpoints.

Returns:



40
41
42
# File 'lib/lockstep_sdk/lockstep_api.rb', line 40

def attachments
  @attachments
end

#code_definitionsCodeDefinitionsClient

Returns Client object for CodeDefinitions endpoints.

Returns:



42
43
44
# File 'lib/lockstep_sdk/lockstep_api.rb', line 42

def code_definitions
  @code_definitions
end

#companiesCompaniesClient

Returns Client object for Companies endpoints.

Returns:



44
45
46
# File 'lib/lockstep_sdk/lockstep_api.rb', line 44

def companies
  @companies
end

#contactsContactsClient

Returns Client object for Contacts endpoints.

Returns:



46
47
48
# File 'lib/lockstep_sdk/lockstep_api.rb', line 46

def contacts
  @contacts
end

#credit_memo_appliedCreditMemoAppliedClient

Returns Client object for CreditMemoApplied endpoints.

Returns:



48
49
50
# File 'lib/lockstep_sdk/lockstep_api.rb', line 48

def credit_memo_applied
  @credit_memo_applied
end

#currenciesCurrenciesClient

Returns Client object for Currencies endpoints.

Returns:



50
51
52
# File 'lib/lockstep_sdk/lockstep_api.rb', line 50

def currencies
  @currencies
end

#custom_field_definitionsCustomFieldDefinitionsClient

Returns Client object for CustomFieldDefinitions endpoints.

Returns:



52
53
54
# File 'lib/lockstep_sdk/lockstep_api.rb', line 52

def custom_field_definitions
  @custom_field_definitions
end

#custom_field_valuesCustomFieldValuesClient

Returns Client object for CustomFieldValues endpoints.

Returns:



54
55
56
# File 'lib/lockstep_sdk/lockstep_api.rb', line 54

def custom_field_values
  @custom_field_values
end

#definitionsDefinitionsClient

Returns Client object for Definitions endpoints.

Returns:



56
57
58
# File 'lib/lockstep_sdk/lockstep_api.rb', line 56

def definitions
  @definitions
end

#emailsEmailsClient

Returns Client object for Emails endpoints.

Returns:



58
59
60
# File 'lib/lockstep_sdk/lockstep_api.rb', line 58

def emails
  @emails
end

#envString

Returns The name or URL of the environment.

Returns:

  • (String)

    The name or URL of the environment



30
31
32
# File 'lib/lockstep_sdk/lockstep_api.rb', line 30

def env
  @env
end

#invoice_historyInvoiceHistoryClient

Returns Client object for InvoiceHistory endpoints.

Returns:



60
61
62
# File 'lib/lockstep_sdk/lockstep_api.rb', line 60

def invoice_history
  @invoice_history
end

#invoicesInvoicesClient

Returns Client object for Invoices endpoints.

Returns:



62
63
64
# File 'lib/lockstep_sdk/lockstep_api.rb', line 62

def invoices
  @invoices
end

#leadsLeadsClient

Returns Client object for Leads endpoints.

Returns:



64
65
66
# File 'lib/lockstep_sdk/lockstep_api.rb', line 64

def leads
  @leads
end

#notesNotesClient

Returns Client object for Notes endpoints.

Returns:



66
67
68
# File 'lib/lockstep_sdk/lockstep_api.rb', line 66

def notes
  @notes
end

#payment_applicationsPaymentApplicationsClient

Returns Client object for PaymentApplications endpoints.

Returns:



68
69
70
# File 'lib/lockstep_sdk/lockstep_api.rb', line 68

def payment_applications
  @payment_applications
end

#paymentsPaymentsClient

Returns Client object for Payments endpoints.

Returns:



70
71
72
# File 'lib/lockstep_sdk/lockstep_api.rb', line 70

def payments
  @payments
end

#provisioningProvisioningClient

Returns Client object for Provisioning endpoints.

Returns:



72
73
74
# File 'lib/lockstep_sdk/lockstep_api.rb', line 72

def provisioning
  @provisioning
end

#reportsReportsClient

Returns Client object for Reports endpoints.

Returns:



74
75
76
# File 'lib/lockstep_sdk/lockstep_api.rb', line 74

def reports
  @reports
end

#statusStatusClient

Returns Client object for Status endpoints.

Returns:



76
77
78
# File 'lib/lockstep_sdk/lockstep_api.rb', line 76

def status
  @status
end

#syncSyncClient

Returns Client object for Sync endpoints.

Returns:

  • (SyncClient)

    Client object for Sync endpoints



78
79
80
# File 'lib/lockstep_sdk/lockstep_api.rb', line 78

def sync
  @sync
end

#user_accountsUserAccountsClient

Returns Client object for UserAccounts endpoints.

Returns:



80
81
82
# File 'lib/lockstep_sdk/lockstep_api.rb', line 80

def user_accounts
  @user_accounts
end

#user_rolesUserRolesClient

Returns Client object for UserRoles endpoints.

Returns:



82
83
84
# File 'lib/lockstep_sdk/lockstep_api.rb', line 82

def user_roles
  @user_roles
end

#versionString

Returns The version number of this Lockstep API client.

Returns:

  • (String)

    The version number of this Lockstep API client



28
29
30
# File 'lib/lockstep_sdk/lockstep_api.rb', line 28

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



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 146

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
    request["Accept"] = 'application/json'
    request["Content-Type"] = 'application/*+json'
    request.body = body
    
    # 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

Parameters:



130
131
132
133
# File 'lib/lockstep_sdk/lockstep_api.rb', line 130

def with_api_key(api_key)
    @bearer_token = nil
    @api_key = api_key
end

#with_bearer_token(bearer_token) ⇒ Object

Configure this API client to use JWT Bearer Token authentication

Parameters:



138
139
140
141
# File 'lib/lockstep_sdk/lockstep_api.rb', line 138

def with_bearer_token(bearer_token)
    @api_key = nil
    @bearer_token = bearer_token
end