تنظیم کلید و توکن

access_key :
به هر یک از کسب وکارها که در سرویس عضو می شوند یک کلید اختصاصی تعلق میگیرد این کلید پس از تکمیل عضویت در سرویس در صفحه پیشخان نمایش داده می شود

Email & Password :
ایمیل و رمز عبوری که به وسیله آن به پنل هاب نت وارد می شوید

توجه :
بهتر است کد زیر در فایلی جداگانه قرار داده شده و سپس فراخوانی شوند و از افشای آنها جدا خودداری فرمایید


                                 
  <? php
         $access_key = '••••••';
         $email = '••••••';
         $password = '••••••';
                
         $headers = array(
          'Content-Type: application/x-www-form-urlencoded',
'Accept: application/json', 'AccessKey: ' . $access_key, );


import 'package:http/http.dart' as http;
import 'dart:convert';

class ApiService {

  final String accessKey = '••••••';
  final String email = '••••••';
  final String password = '••••••';

  final Map < String, String > headers = {
  
    'Content-Type': 'application/x-www-form-urlencoded',
    'Accept': 'application/json',
    'AccessKey': '••••••',
    
  };


                   
                       
import Foundation

struct API {
    static let accessKey = "••••••"
    static let email = "••••••"
    static let password = "••••••"
    
    static let headers: [String: String] = [
        "Content-Type": "application/x-www-form-urlencoded",
        "Accept": "application/json",
        "AccessKey": accessKey
    ]



                   
                   
import requests

access_key = '••••••'
email = '••••••'
password = '••••••'

headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Accept': 'application/json',
    'AccessKey': access_key
} 
                    


                   
import axios from 'axios';

const accessKey = '••••••';
const email = '••••••';
const password = '••••••';

const headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
  'Accept': 'application/json',
  'AccessKey': accessKey,
};                   
                



using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class Program
{
    private static readonly string accessKey = "••••••";
    private static readonly string email = "••••••";
    private static readonly string password = "••••••";

    private static readonly Dictionary<string, string> headers = new Dictionary<string, string>
    {
        { "Content-Type", "application/x-www-form-urlencoded" },
        { "Accept", "application/json" },
        { "AccessKey", accessKey }
    };

پس از قرار دادن موارد بالا ، پارامترهایی که مد نظر دارید را به صورت زیر قرار دهید

BusinessCode :
هرکسب و کاری کدی ثابت مخصوص به خود را دارد . پس از عضویت در سرویس این کد ایجاد میگردد و در این قسمت قرار داده می شود


                  
   $global_params = array ( 
                    
    'BusinessCode' => '••••••'
                   
   );
                   
 


 final Map globalParams = {
 
    'BusinessCode': '••••••',
    
  };


                          
    static let globalParams: [String: String] = [
        "BusinessCode": "••••••"
    ]                       
                          

                          
                          
global_params = {
    'BusinessCode': '••••••'
}                    
                          

                          
                          
const globalParams = {
  BusinessCode: '••••••',
};                   
                          
    

 private static readonly Dictionary<string, string> globalParams = new Dictionary<string, string>
    {
        { "BusinessCode", "••••••" }
    };
    
    
آدرس های وب سرویس به شرح زیر می باشد :

GetToken :
آدرس سرویس دریافت توکن

PurchaseRewards :
آدرس سرویس خرید و دریافت پاداش

UserWalletCredit :
آدرس سرویس نمایش موجودی اعتبار مشتری

AddOrLoginUser :
آدرس سرویس عضویت ، ورود یا تایید خرید از اعتبار کاربر

VerifyUserIdentity :
آدرس سرویس تایید هویت دو مرحله ای کاربر جهت عضویت ، ورود یا تایید خرید

ListProduct :
آدرس سرویس نمایش لیست محصولات ، درصد پاداش هر محصول و ... در وب سایت

             
 
$api_urls = array(
          'get_token' => 'https://hubnetunity.com/api/v1/GetToken',
          'purchase_rewards' => 'https://hubnetunity.com/api/v1/PurchaseRewards',
          'user_wallet_credit' => 'https://hubnetunity.com/api/v1/UserWalletCredit',
          'add_or_login_user' => 'https://hubnetunity.com/api/v1/AddOrLoginUser',
          'verify_user_identity' => 'https://hubnetunity.com/api/v1/VerifyUserIdentity',
          'list_product' => 'https://hubnetunity.com/api/v1/ListProduct'
      );             
             
  
                        
  final Map < String, String > apiUrls = {
 
    'get_token': 'https://hubnetunity.com/api/v1/GetToken',
    'purchase_rewards': 'https://hubnetunity.com/api/v1/PurchaseRewards',
    'user_wallet_credit': 'https://hubnetunity.com/api/v1/UserWalletCredit',
    'add_or_login_user': 'https://hubnetunity.com/api/v1/AddOrLoginUser',
    'verify_user_identity': 'https://hubnetunity.com/api/v1/VerifyUserIdentity',
    'list_product': 'https://hubnetunity.com/api/v1/ListProduct',
    
  };

 
                
 static let apiUrls: [String: String] = [
        "getToken": "https://hubnetunity.com/api/v1/GetToken",
        "purchaseRewards": "https://hubnetunity.com/api/v1/PurchaseRewards",
        "userWalletCredit": "https://hubnetunity.com/api/v1/UserWalletCredit",
        "addOrLoginUser": "https://hubnetunity.com/api/v1/AddOrLoginUser",
        "verifyUserIdentity": "https://hubnetunity.com/api/v1/VerifyUserIdentity",
        "listProduct": "https://hubnetunity.com/api/v1/ListProduct"
    ]
}
                           

                          
api_urls = {
    'get_token': 'https://hubnetunity.com/api/v1/GetToken',
    'purchase_rewards': 'https://hubnetunity.com/api/v1/PurchaseRewards',
    'user_wallet_credit': 'https://hubnetunity.com/api/v1/UserWalletCredit',
    'add_or_login_user': 'https://hubnetunity.com/api/v1/AddOrLoginUser',
    'verify_user_identity': 'https://hubnetunity.com/api/v1/VerifyUserIdentity',
    'list_product': 'https://hubnetunity.com/api/v1/ListProduct'
}                    
                          

                          
const apiUrls = {
  getToken: 'https://hubnetunity.com/api/v1/GetToken',
  purchaseRewards: 'https://hubnetunity.com/api/v1/PurchaseRewards',
  userWalletCredit: 'https://hubnetunity.com/api/v1/UserWalletCredit',
  addOrLoginUser: 'https://hubnetunity.com/api/v1/AddOrLoginUser',
  verifyUserIdentity: 'https://hubnetunity.com/api/v1/VerifyUserIdentity',
  listProduct: 'https://hubnetunity.com/api/v1/ListProduct',
};                   
                          


private static readonly Dictionary<string, string> apiUrls = new Dictionary<string, string>
    {
        { "get_token", "https://hubnetunity.com/api/v1/GetToken" },
        { "purchase_rewards", "https://hubnetunity.com/api/v1/PurchaseRewards" },
        { "user_wallet_credit", "https://hubnetunity.com/api/v1/UserWalletCredit" },
        { "add_or_login_user", "https://hubnetunity.com/api/v1/AddOrLoginUser" },
        { "verify_user_identity", "https://hubnetunity.com/api/v1/VerifyUserIdentity" },
        { "list_product", "https://hubnetunity.com/api/v1/ListProduct" }
    };
    
    

تابع جهت ایجاد در خواست های cURL و بررسی لینک های سرویس جهت ارسال وپاسخ از طریق HTTPS

   
 
function make_curl_request($url, $postfields, $headers) {

      if (strpos($url, 'https://') !== 0) {
      
          die('Unsecure connection detected. Data transmission aborted.');
        }

                 $curl = curl_init( );
                  curl_setopt_array($curl, array(
                  CURLOPT_URL => $url,
                  CURLOPT_RETURNTRANSFER => true,
                  CURLOPT_ENCODING => '',
                  CURLOPT_MAXREDIRS => 10,
                  CURLOPT_TIMEOUT => 0,
                  CURLOPT_FOLLOWLOCATION => true,
                  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                  CURLOPT_CUSTOMREQUEST => 'POST',
                  CURLOPT_POSTFIELDS => http_build_query($postfields),
                  CURLOPT_HTTPHEADER => $headers,
                ));
                
    $response = curl_exec($curl);
                curl_close($curl);
                     return $response;
  }
  
 


               
Future < String > makeRequest(String url, Map < String, String > body) async {
    final response = await http.post(
      Uri.parse(url),
      headers: headers,
      body: body,
    );

 if (response.statusCode == 200) {
      return response.body;
    } else {
      throw Exception('Failed to load data');
    }
  }



func makeRequest(url: String, params: [String: String], headers: [String: String], completion: @escaping (Data?, URLResponse?, Error?) -> Void) {
    guard let url = URL(string: url), url.scheme == "https" else {
        print("Unsecure connection detected. Data transmission aborted.")
        return
    }
    
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.allHTTPHeaderFields = headers
    request.httpBody = params.map { "\($0.key)=\($0.value)" }.joined(separator: "&").data(using: .utf8)
    
    let task = URLSession.shared.dataTask(with: request, completionHandler: completion)
    task.resume()
}



                          
def make_request(url, data, headers):
    if not url.startswith('https://'):
        raise ValueError('Unsecure connection detected. Data transmission aborted.')
    
    response = requests.post(url, data=data, headers=headers)
    return response.json()                    
                          

                          
const makeRequest = async (url, data, headers) => {
  if (!url.startsWith('https://')) {
    throw new Error('Unsecure connection detected. Data transmission aborted.');
  }

  try {
    const response = await axios.post(url, new URLSearchParams(data), { headers });
    return response.data;
  } catch (error) {
    console.error('Error making request:', error);
    throw error;
  }
};                  
                          



 private static async Task<string> MakeHttpRequest(string url, Dictionary<string, string> postfields, Dictionary<string, string> headers)
    {
        using (var client = new HttpClient())
        {
            if (!url.StartsWith("https://"))
            {
                throw new InvalidOperationException("Unsecure connection detected. Data transmission aborted.");
            }

            var content = new FormUrlEncodedContent(postfields);
            foreach (var header in headers)
            {
                client.DefaultRequestHeaders.Add(header.Key, header.Value);
            }

            var response = await client.PostAsync(url, content);
            response.EnsureSuccessStatusCode();

            return await response.Content.ReadAsStringAsync();
        }
    }
    
    
    
درخواست یا بروزرسانی توکن به شرح زیر می باشد :

توجه :
توکن هر 1 ساعت منقضی شده و میبایست یک توکن جدید ایجاد کرد میتوان کد زیر را در کرون جاب اجرا کرد و پس از یک ساعت درخواست توکن جدید داد

 
             
    $token_response = make_curl_request($api_urls['get_token'], array(
      'Email' => $email,
      'Password' => $password
       ), $headers);
          $token_data = json_decode($token_response, true);
          $headers[ ] = 'Authorization: Bearer ' . $token_data['BearerToken']['token'];
             echo $token_response;
             
                   
 

 Future < void > getToken() async {
    final response = await makeRequest(apiUrls['get_token']!, {
    
      'Email': email,
      'Password': password,
      
    });

    final tokenData = json.decode(response);
    
    headers['Authorization'] = 'Bearer ${tokenData['BearerToken']['token']}';
    
    print(response);
  }

 
                          
<?php 

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/GetToken',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'Email=test%40gmail.com&Password=25445585',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json'
  ),
));                          
                          
 

func getToken(completion: @escaping (String?) -> Void) {
    let params = ["Email": API.email, "Password": API.password]
    
    makeRequest(url: API.apiUrls["getToken"]!, params: params, headers: API.headers) { data, response, error in
        guard let data = data, error == nil else {
            completion(nil)
            return
        }
        
        if let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
           let token = json["BearerToken"] as? [String: Any],
           let tokenString = token["token"] as? String {
            completion(tokenString)
        } else {
            completion(nil)
        }
    }
}


                          
token_response = make_request(api_urls['get_token'], {
    'Email': email,
    'Password': password
}, headers)

token_data = token_response['BearerToken']['token']
headers['Authorization'] = f'Bearer {token_data}'

print(token_response)                    
                          

                          
const main = async () => {
  try {
    const tokenResponse = await makeRequest(apiUrls.getToken, { Email: email, Password: password }, headers);
    const tokenData = tokenResponse.BearerToken.token;
    headers['Authorization'] = `Bearer ${tokenData}`;

    console.log(tokenResponse);                
                          
   


 public static async Task Main(string[] args)
    {
        var tokenResponse = await MakeHttpRequest(apiUrls["get_token"], new Dictionary<string, string>
        {
            { "Email", email },
            { "Password", password }
        }, headers);

        var tokenData = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(tokenResponse);
        headers.Add("Authorization", "Bearer " + tokenData["BearerToken"]["token"]);

        Console.WriteLine(tokenResponse);
        
        
        

عضویت ، ورود یا تایید خرید از اعتبار کیف پول توسط کاربر :

MobileOrEmail :
در این پارامتر ، شماره یا ایمیل کاربر جهت عضویت در سرویس پاداش دهی هاب نت را وارد نمایید

Country :
در این قسمت کد ایزو مربوط به کشوری که کاربر با آن عضو می گردد را وارد نمایید مثال : شماره کاربر 98+ میباشد و کد ایزو اون IR می باشد یا کاربری با شماره 1+ عضو می گردد کد ایزو او US است

ReferrerCode :
در این پارامتر کاربر عضو شونده می تواند کد بازاریابی شخصی که کسب و کار شما را معرفی کرده است را وارد نماید( این پارامتر اختیاری می باشد و میتوان آن را خالی گذاشت)

                
                
$login_response = make_curl_request($api_urls['add_or_login_user'], array_merge($global_params, array(

          'MobileOrEmail' => '••••••',
          'Country' => '••••••',
          'ReferrerCode' => '••••••'
                           )), $headers);
  echo $login_response;                                 
                 
 

Future < void > addOrLoginUser() async {
    final response = await makeRequest(apiUrls['add_or_login_user']!, {
    
      ...globalParams,
      'MobileOrEmail': '••••••',
      'Country': '••••••',
      'ReferrerCode': '••••••',
      
    });

    print(response);
  }



<?php

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/AddOrLoginUser',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'BusinessCode=••••••&MobileOrEmail=••••••&Country=IR&ReferrerCode=••••••',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json',
    'AccessKey: ••••••',
    'Authorization: Bearer ••••••'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
                          


func addOrLoginUser(token: String, completion: @escaping (Data?) -> Void) {
    var headers = API.headers
    headers["Authorization"] = "Bearer \(token)"
    
    var params = API.globalParams
    params["MobileOrEmail"] = "••••••"
    params["Country"] = "••••••"
    params["ReferrerCode"] = "••••••"
    
    makeRequest(url: API.apiUrls["addOrLoginUser"]!, params: params, headers: headers) { data, response, error in
        completion(data)
    }
}
                          

                          
login_response = make_request(api_urls['add_or_login_user'], {
    **global_params,
    'MobileOrEmail': '••••••',
    'Country': '••••••',
    'ReferrerCode': '••••••'
}, headers)

print(login_response)                    
                          

                          
const loginResponse = await makeRequest(apiUrls.addOrLoginUser, {
      ...globalParams,
      MobileOrEmail: '••••••',
      Country: '••••••',
      ReferrerCode: '••••••',
    }, headers);
    console.log(loginResponse);                   
                          


 var loginResponse = await MakeHttpRequest(apiUrls["add_or_login_user"], new Dictionary<string, string>(globalParams)
        {
            { "MobileOrEmail", "••••••" },
            { "Country", "••••••" },
            { "ReferrerCode", "••••••" }
        }, headers);

        Console.WriteLine(loginResponse);
        
        

تایید دو مرحله ای عضویت ، ورود یا خرید از اعتبار کیف پول توسط کاربر :

توجه :
این قسمت جهت تایید دومرحله ای عضویت ، ورود یا خرید از اعتبار کیف پول توسط کاربر می باشد و مقادیر آن نیز باید با کد قبل مطابقت داشته باشد

MobileOrEmail :
در این پارامتر شماره همراه یا ایمیل کاربر که در وب سرویس عضویت یا ورود وارده کرده اید را قرار دهید

Country :
این قسمت نیز مانند کد قبل (عضویت ) باید یکسان باشد

Otp :
این پارامتر تایید دو مرحله ای کاربر است ، کاربر پس از دریافت کد پیامک شده به شماره همراه یا ایمیل ، کد دریافتی خود را در این قسمت وارد نماید


                 
$verify_response = make_curl_request($api_urls['verify_user_identity'], array_merge($global_params, array(
      'MobileOrEmail' => '••••••',
      'Country' => '••••••',
      'Otp' => '••••••'
    )), $headers);
       echo $verify_response;
                
  

 Future < void > verifyUserIdentity() async {
    final response = await makeRequest(apiUrls['verify_user_identity']!, {
    
      ...globalParams,
      'MobileOrEmail': '••••••',
      'Country': '••••••',
      'Otp': '••••••',
      
    });

    print(response);
  }

  

<?php
              
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/VerifyUserIdentity',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'BusinessCode=••••••&MobileOrEmail=••••••&Country=IR&Otp=••••••',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json',
    'AccessKey: ••••••',
    'Authorization: Bearer ••••••'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;     
                     
  


 func verifyUserIdentity(token: String, completion: @escaping (Data?) -> Void) {
    var headers = API.headers
    headers["Authorization"] = "Bearer \(token)"
    
    var params = API.globalParams
    params["MobileOrEmail"] = "••••••"
    params["Country"] = "••••••"
    params["Otp"] = "••••••"
    
    makeRequest(url: API.apiUrls["verifyUserIdentity"]!, params: params, headers: headers) { data, response, error in
        completion(data)
    }
}           
                     
                     

                          
verify_response = make_request(api_urls['verify_user_identity'], {
    **global_params,
    'MobileOrEmail': '••••••',
    'Country': '••••••',
    'Otp': '••••••'
}, headers)

print(verify_response)                    
                          

                          
const verifyResponse = await makeRequest(apiUrls.verifyUserIdentity, {
      ...globalParams,
      MobileOrEmail: '••••••',
      Country: '••••••',
      Otp: '••••••',
    }, headers);
    console.log(verifyResponse);                  
                          



   var verifyResponse = await MakeHttpRequest(apiUrls["verify_user_identity"], new Dictionary<string, string>(globalParams)
        {
            { "MobileOrEmail", "••••••" },
            { "Country", "••••••" },
            { "Otp", "••••••" }
        }, headers);

        Console.WriteLine(verifyResponse);
        
        
        

خرید از اعتبار کیف پول یا خرید بدون استفاده از اعتبار توسط کاربر و دریافت پاداش از خرید :

توجه :
دریافت پاداش از خرید به دو صورت امکان پذیر است ، میتوان وب سرویس ورود یا عضویت که قبلا توضیح داده شده را برای مشتریان جدید نمایش داد تا بتوانند از این طریق با کد معرفشان عضو سیستم کشبک گردند یا مشتری میتواند بدون ورود یا عضویت خرید خود را انجام دهد که در این صورت مشتری به صورت خودکار عضو سرویس میگردد و پاداش خود را دریافت می نماید اما دراین صورت امکان عضویت مجدد با کدمعرف در این کسب وکار وجود نخواهد داشت

BusinessCode :
دراین قسمت کد کسب وکار وارد می شود

ProductCode :
دراین قسمت کد محصول وارد می شود . درصورتیکه کد محصول در پنل بر اساس بازه مبلغ تنظیم شده باشد این قسمت را باید خالی ارسال کرد

AmountPurchase :
مبلغ محصولات و یا مبلغ سبد خرید را در این پارامتر وارد نمایید.توجه نمایید که این پارامتر در خرید از اعتبار کیف پول و یا غیر از آن باید همچنان رقم خرید داده شود

UseAmountCredit :
در صورتی که مشتری قصد دارد از اعتبار کیف پول خود خرید نماید در این پارامتر مقدار مبلغ درخواستی او را وارد نمایید .دقت نمایید که مبلغ این قسمت باید کوچکتر یا مساوی مبلغ UseAmountCredit باشد درصورتی که خرید از اعتبار صورت نگرفته رقم این پارامتر را برابر با 0 قرار دهید

MobileOrEmail :
در این پارامتر شماره یا ایمیل خریدار قرار میگیرد ( در حال حاضر تنها شماره همراه فعال می باشد)

Description :
این پارامتر به صورت اختیاری می باشد در اینجا میتوناید توضیحاتی در مورد محصول یا کد محصول در سایت خودتان و ..مواردی ازاین قبیل به اختیار خود وارد نمایید. این پارامتر کمک خوبی در زمینه بررسی خریدهای محصول در پنل هاب نت به شما خواهد کرد توجه داشته باشید که در این پارامتر حداکثر مجاز ورودی آن 30 حرف می باشد

MarketerCode :
در صورتی که به عنوان همکار هاب نت مشغول به بازاریابی هستید کد بازاریابی خود را در این پارامتر قرار دهید درغیر این صورت پیشفرض عدد 0 قرار دهید

نکته اول :
خرید از اعتبار نیاز به ورود و تایید هویت دارد که در حال حاضر تنها با استفاده از سرویس ورود و تایید هویت امکان پذیر است و تنها 10 دقیقه امکان خرید از اعتبار وجود دارد ، این زمان ممکن است تغییر نماید که اطلاع رسانی خواهد شد

نکته دوم :
جهت خرید بدون استفاده از اعتبار کیف پول نیاز به ورود مجدد ندارد و تنها عضویت اولیه کاربر (یکبار اول که انجام میشود ) کافی می باشد

            
        
             
$data = [
    ['ProductCode' => '••••••', 'AmountPurchase' => ••••••, 'Description' => '••••••', 'MarketerCode' => '••••••'],
    ['ProductCode' => '••••••', 'AmountPurchase' => ••••••, 'Description' => '••••••', 'MarketerCode' => '••••••'],
    
];

$useAmountCredit = ••••••; 
$MobileOrEmail = '••••••'; 

$params['MobileOrEmail'] = $MobileOrEmail;
$params['UseAmountCredit'] = $useAmountCredit;

foreach ($data as $item) {
    $params['ProductCode'] = $item['ProductCode'];
    $params['AmountPurchase'] = $item['AmountPurchase'];
    $params['Description'] = $item['Description'];
    $params['MarketerCode'] = $item['MarketerCode'];

    $purchase_response = make_curl_request(
        $api_urls['purchase_rewards'], 
        array_merge($global_params, $params), 
        $headers
    );
}

echo $purchase_response;

                  
                  
 


Future<void> makePurchases() async {
  var data = [
    {'ProductCode': '••••••', 'AmountPurchase': '••••••', 'Description': '••••••', 'MarketerCode': '••••••'},
    {'ProductCode': '••••••', 'AmountPurchase': '••••••', 'Description': '••••••', 'MarketerCode': '••••••'},
  ];

  var useAmountCredit = '••••••';
  var mobileOrEmail = '••••••';

  var params = {
    'MobileOrEmail': mobileOrEmail,
    'UseAmountCredit': useAmountCredit,
  };

  var purchaseRewardsUrl = 'purchase_rewards'; 

  for (var item in data) {
    params['ProductCode'] = item['ProductCode'];
    params['AmountPurchase'] = item['AmountPurchase'];
    params['Description'] = item['Description'];
    params['MarketerCode'] = item['MarketerCode'];

    var purchaseResponse = await makeHttpRequest(
      purchaseRewardsUrl, 
      {...globalParams, ...params},
      headers,
    );

    print(purchaseResponse);
  }
}

void main() {
  makePurchases();
}

Future<String> makeHttpRequest(String url, Map<String, dynamic> params, Map<String, String> headers) async {
  var response = await http.post(
    Uri.parse(url),
    body: params,
    headers: headers,
  );

  if (response.statusCode == 200) {
    return response.body;
  } else {
    throw Exception('Failed to load data');
  }
}




 


<?php

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/PurchaseRewards',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'BusinessCode=•••••&ProductCode=•••••&AmountPurchase=•••••&UseAmountCredit=•••••&MobileOrEmail=•••••&Description=•••••&MarketerCode=•••••',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json',
    'AccessKey:  ••••••',
    'Authorization: Bearer ••••••'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
                          
 


func purchaseRewards(token: String, data: [[String: Any]], completion: @escaping (Data?) -> Void) {
    var headers = API.headers
    headers["Authorization"] = "Bearer \(token)"
    
    var params = API.globalParams
    params["MobileOrEmail"] = "••••••"
    params["UseAmountCredit"] = "••••••"
    
    for item in data {
        params["ProductCode"] = item["ProductCode"] as? String
        params["AmountPurchase"] = item["AmountPurchase"] as? String
        params["Description"] = item["Description"] as? String
        params["MarketerCode"] = item["MarketerCode"] as? String
        
        makeRequest(url: API.apiUrls["purchaseRewards"]!, params: params, headers: headers) { data, response, error in
            completion(data)
        }
    }
}

                           

 
                          
data = [
    {'ProductCode': '••••••', 'AmountPurchase': '••••••', 'Description': '••••••', 'MarketerCode': '••••••'},
    {'ProductCode': '••••••', 'AmountPurchase': '••••••', 'Description': '••••••', 'MarketerCode': '••••••'},
]

use_amount_credit = '••••••'
mobile_or_email = '••••••'

params = {
    'MobileOrEmail': mobile_or_email,
    'UseAmountCredit': use_amount_credit
}

for item in data:
    params.update(item)
    purchase_response = make_request(api_urls['purchase_rewards'], {
        **global_params,
        **params
    }, headers)
    print(purchase_response)
                
                          

    
                          
const data = [
  { ProductCode: '••••••', AmountPurchase: '••••••', Description: '••••••', MarketerCode: '••••••' },
  { ProductCode: '••••••', AmountPurchase: '••••••', Description: '••••••', MarketerCode: '••••••' },
];

const useAmountCredit = '••••••';
const MobileOrEmail = '••••••';

for (const item of data) {
  const purchaseResponse = await makeRequest(apiUrls.purchaseRewards, {
    ...globalParams,
    MobileOrEmail,
    UseAmountCredit: useAmountCredit,
    ProductCode: item.ProductCode,
    AmountPurchase: item.AmountPurchase,
    Description: item.Description,
    MarketerCode: item.MarketerCode,
  }, headers);
  console.log(purchaseResponse);
}
      
            
                          



var data = new List<Dictionary<string, string>>
{
    new Dictionary<string, string> { { "ProductCode", "••••••" }, { "AmountPurchase", "••••••" }, { "Description", "••••••" }, { "MarketerCode", "••••••" } },
    new Dictionary<string, string> { { "ProductCode", "••••••" }, { "AmountPurchase", "••••••" }, { "Description", "••••••" }, { "MarketerCode", "••••••" } }
};

var useAmountCredit = "••••••";
var mobileOrEmail = "••••••";

var paramsDict = new Dictionary<string, string>(globalParams)
{
    { "MobileOrEmail", mobileOrEmail },
    { "UseAmountCredit", useAmountCredit }
};

foreach (var item in data)
{
    paramsDict["ProductCode"] = item["ProductCode"];
    paramsDict["AmountPurchase"] = item["AmountPurchase"];
    paramsDict["Description"] = item["Description"];
    paramsDict["MarketerCode"] = item["MarketerCode"];

    var purchaseResponse = await MakeHttpRequest(apiUrls["purchase_rewards"], paramsDict, headers);
    Console.WriteLine(purchaseResponse);
}
        
        
نمایش اعتبار کیف پول به کاربر :

MobileOrEmail :
در این پارامتر همانند موارد قبل شماره همراه یا ایمیل کاربر قرار داده می شود

توجه :
این قسمت پس از اولین عضویت توسط کاربر برای همیشه قابل مشاهده است و نیاز به ورود مجدد ندارد

        
     
             
  $wallet_response = make_curl_request($api_urls['user_wallet_credit'], array_merge($global_params, array(
  
           'MobileOrEmail' => '••••••'
           
     )), $headers);
     
      echo $wallet_response;      
               
                 
  
               
 Future getUserWalletCredit() async {
    final response = await makeRequest(apiUrls['user_wallet_credit']!, {
    
      ...globalParams,
      'MobileOrEmail': '••••••',
      
    });

    print(response);
    
  }
               
  
         
<?php

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/UserWalletCredit',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'BusinessCode=••••••&MobileOrEmail=••••••',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json',
    'AccessKey: ••••••',
    'Authorization: Bearer ••••••'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
                         
  
         
         
func userWalletCredit(token: String, completion: @escaping (Data?) -> Void) {
    var headers = API.headers
    headers["Authorization"] = "Bearer \(token)"
    
    var params = API.globalParams
    params["MobileOrEmail"] = "••••••"
    
    makeRequest(url: API.apiUrls["userWalletCredit"]!, params: params, headers: headers) { data, response, error in
        completion(data)
    }
}
                        
                         

                          
wallet_response = make_request(api_urls['user_wallet_credit'], {
    **global_params,
    'MobileOrEmail': '••••••'
}, headers)

print(wallet_response)                
                          

                          
 const walletResponse = await makeRequest(apiUrls.userWalletCredit, {
      ...globalParams,
      MobileOrEmail: '••••••',
    }, headers);
    console.log(walletResponse);                
                          


 var walletResponse = await MakeHttpRequest(apiUrls["user_wallet_credit"], new Dictionary<string, string>(globalParams)
        {
            { "MobileOrEmail", "••••••" }
        }, headers);

        Console.WriteLine(walletResponse);

نمایش لیست درصد و مبالغ و محصولات تنظیم شده در سرویس هاب نت :

با استفاده از این کد میتوانید درصد محصولات و مواردی مانند درصد پاداش آن محصول را در وب سایت خود به نمایش در آورید

 
             
  $list_response = make_curl_request(
     
     $api_urls['list_product'], $global_params, $headers);
     
       echo $list_response;
       
   ?>
                 

            
 Future<void> listProduct() async {
 
    final response = await makeRequest(apiUrls['list_product']!, globalParams);

    print(response);
    
  }
}

   

<?php 

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hubnetunity.com/api/v1/ListProduct',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'BusinessCode=••••••',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json',
    'AccessKey: ••••••',
    'Authorization: Bearer ••••••'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;          
                          
   

func listProduct(token: String, completion: @escaping (Data?) -> Void) {
    var headers = API.headers
    headers["Authorization"] = "Bearer \(token)"
    
    makeRequest(url: API.apiUrls["listProduct"]!, params: API.globalParams, headers: headers) { data, response, error in
        completion(data)
    }
}      
                          

                          
list_response = make_request(api_urls['list_product'], global_params, headers)
print(list_response)                    
                          

                          
 const listResponse = await makeRequest(apiUrls.listProduct, globalParams, headers);
    console.log(listResponse);
  } catch (error) {
    console.error('Error in main function:', error);
  }
};

main();                  
                          


 var listResponse = await MakeHttpRequest(apiUrls["list_product"], globalParams, headers);
        Console.WriteLine(listResponse);
    }