Module: Mass

Defined in:
lib/mass-client.rb,
lib/base-line/job.rb,
lib/base-line/tag.rb,
lib/base-line/lead.rb,
lib/base-line/rule.rb,
lib/base-line/event.rb,
lib/base-line/source.rb,
lib/base-line/channel.rb,
lib/base-line/company.rb,
lib/base-line/profile.rb,
lib/base-line/request.rb,
lib/base-line/revenue.rb,
lib/base-line/industry.rb,
lib/base-line/location.rb,
lib/base-line/outreach.rb,
lib/base-line/data_type.rb,
lib/base-line/headcount.rb,
lib/base-line/enrichment.rb,
lib/base-line/inboxcheck.rb,
lib/base-line/source_type.rb,
lib/base-line/unsubscribe.rb,
lib/base-line/profile_type.rb,
lib/first-line/profile_api.rb,
lib/first-line/profile_mta.rb,
lib/first-line/profile_rpa.rb,
lib/base-line/outreach_type.rb,
lib/base-line/connectioncheck.rb,
lib/base-line/enrichment_type.rb

Overview

mass client configuration

Defined Under Namespace

Classes: Channel, Company, ConnectionCheck, DataType, Enrichment, EnrichmentType, Event, Headcount, InboxCheck, Industry, Job, Lead, Location, Outreach, OutreachType, Profile, ProfileAPI, ProfileMTA, ProfileRPA, ProfileType, Request, Revenue, Rule, Source, SourceType, Tag, Unsubscribe

Class Method Summary collapse

Class Method Details

.download_pathObject



121
122
123
# File 'lib/mass-client.rb', line 121

def self.download_path
    @@download_path
end

.js_pathObject



125
126
127
# File 'lib/mass-client.rb', line 125

def self.js_path
    @@js_path
end

.s3Object



145
146
147
# File 'lib/mass-client.rb', line 145

def self.s3
    @@s3
end

.s3_access_key_idObject



133
134
135
# File 'lib/mass-client.rb', line 133

def self.s3_access_key_id
    @@s3_access_key_id
end

.s3_bucketObject



141
142
143
# File 'lib/mass-client.rb', line 141

def self.s3_bucket
    @@s3_bucket
end

.s3_regionObject



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

def self.s3_region
    @@s3_region
end

.s3_secret_access_keyObject



137
138
139
# File 'lib/mass-client.rb', line 137

def self.s3_secret_access_key
    @@s3_secret_access_key
end

.set(api_key:, subaccount: nil, api_url: 'https://massprospecting.com', api_port: 443, api_version: '1.0', backtrace: false, js_path: nil, download_path: [], s3_region: nil, s3_access_key_id: nil, s3_secret_access_key: nil, s3_bucket: nil) ⇒ Object

set the MassProspecting API client

Parameters:

api_key: Mandatory. The API key of your MassProspecting account. subaccount: Optional. The name of the subaccount you want to work with. If you provide a subaccount, the SDK will call the master to get the URL and port of the subaccount. Default is nil.

api_url: Optional. The URL of the MassProspecting API. Default is ‘massprospecting.com’. api_port: Optional. The port of the MassProspecting API. Default is 443. api_version: Optional. The version of the MassProspecting API. Default is ‘1.0’.

backtrace: Optional. If true, the backtrace of the exceptions will be returned by the access points. If false, only an error description is returned. Default is false.

js_path: Optional. The path to the JavaScript file to be used by the SDK. Default is nil. download_path: Optional. The path to the download folder(s) to be used by the SDK. Default is [].



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
111
112
113
114
115
116
117
118
119
# File 'lib/mass-client.rb', line 41

def self.set(
    api_key: ,
    subaccount: nil,

    api_url: 'https://massprospecting.com', 
    api_port: 443,
    api_version: '1.0',

    backtrace: false,

    js_path: nil, 
    download_path: [],

    s3_region: nil,
    s3_access_key_id: nil,
    s3_secret_access_key: nil,
    s3_bucket: nil
)
    # call the master to get the URL and port of the subaccount.
    BlackStack::API.set_client(
        api_key: api_key,
        api_url: api_url,
        api_port: api_port,
        api_version: api_version,
        backtrace: backtrace
    )
    
    if subaccount
        params = { 'name' => subaccount }
        ret = BlackStack::API.post(
            endpoint: "resolve/get",
            params: params
        )

        raise "Error initializing client: #{ret['status']}" if ret['status'] != 'success'
        
        # call the master to get the URL and port of the subaccount.
        BlackStack::API.set_client(
            api_key: ret['api_key'],
            api_url: ret['url'],
            api_port: ret['port'],
            api_version: api_version,
            backtrace: backtrace
        )
    end

    # validate: download_path must be a string or an arrow of strings
    if download_path.is_a?(String)
        raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.") if download_path.to_s.empty?
    elsif download_path.is_a?(Array)
        download_path.each { |p|
            raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.") if p.to_s.empty?
        }
    else
        raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.")
    end

    @@js_path = js_path
    @@download_path = download_path

    @@s3_region = s3_region
    @@s3_access_key_id = s3_access_key_id
    @@s3_secret_access_key = s3_secret_access_key
    @@s3_bucket = s3_bucket

    # Initialize the S3 client
    if (
        @@s3_region
        @@s3_access_key_id
        @@s3_secret_access_key
        @@s3_bucket
    )
        @@s3 = Aws::S3::Client.new(
            region: @@s3_region,
            access_key_id: @@s3_access_key_id,
            secret_access_key: @@s3_secret_access_key
        )
    end
end