Skip to content

divar-ir/kenar-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for kenarapi

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0
  • Package version: 0.1.0
  • Generator version: 7.13.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import kenarapi "github.com/divar-ir/kenar-sdk-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value kenarapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), kenarapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value kenarapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), kenarapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using kenarapi.ContextOperationServerIndices and kenarapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), kenarapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), kenarapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://open-api.divar.ir

Class Method HTTP request Description
AddonsAPI AddonsCreateBusinessAddon Post /v1/open-platform/addons/business/{business_token} افزودن افزونه جدید به آگهی‌های کسب‌و‌کار
AddonsAPI AddonsCreatePostAddonV2 Post /v2/open-platform/addons/post/{token} افزودن افزونه جدید به آگهی
AddonsAPI AddonsCreateUserAddonV2 Post /v2/open-platform/addons/user/{phone} افزودن افزونه جدید به کاربر
AddonsAPI AddonsCreateUserAddonV22 Post /v2/open-platform/addons/users/{divar_user_id} افزودن افزونه جدید به کاربر
AddonsAPI AddonsDeletePostAddon Delete /v1/open-platform/add-ons/post/{token} حذف افزونه از آگهی
AddonsAPI AddonsDeletePostAddon2 Delete /v1/open-platform/addons/post/{token} حذف افزونه از آگهی
AddonsAPI AddonsDeleteUserAddon Delete /v1/open-platform/addons/user/{id} حذف افزونه کاربر
AssetsAPI AssetsGetBodyStatuses Get /v1/open-platform/assets/body-status دریافت گزینه‌های وضعیت بدنه موجود در دسته‌بندی‌های خودرو دیوار
AssetsAPI AssetsGetBrandModels Get /v1/open-platform/assets/brand-model/{category} دریافت مدل‌های برند در دسته‌بندی دیوار
AssetsAPI AssetsGetCategories Get /v1/open-platform/assets/category دریافت دسته‌بندی‌های دیوار
AssetsAPI AssetsGetCities Get /v1/open-platform/assets/city دریافت شهرهای دیوار
AssetsAPI AssetsGetColors Get /v1/open-platform/assets/color/{category} دریافت رنگ‌ها در دسته‌بندی دیوار
AssetsAPI AssetsGetDistricts Get /v1/open-platform/assets/district دریافت مناطق دیوار
AssetsAPI AssetsGetDistricts2 Get /v1/open-platform/assets/district/{city_slug} دریافت مناطق دیوار
AssetsAPI AssetsGetInternalStorages Get /v1/open-platform/assets/internal-storage دریافت گزینه‌های حافظه داخلی موجود در دسته‌بندی‌های موبایل/تبلت/لپ‌تاپ دیوار
AssetsAPI AssetsGetOAuthScopes Get /v1/open-platform/assets/oauth-scope دریافت دامنه‌های OAuth کنار دیوار
AssetsAPI AssetsGetPermissions Get /v1/open-platform/assets/permission دریافت مجوزهای کنار دیوار
AssetsAPI AssetsGetRamMemories Get /v1/open-platform/assets/ram-memory دریافت گزینه‌های حافظه رم موجود در دسته‌بندی‌های موبایل/تبلت/لپ‌تاپ دیوار
AssetsAPI AssetsGetServiceTypes Get /v1/open-platform/assets/service-type دریافت انواع سرویس موجود در کنار دیوار
AssetsAPI AssetsGetSubmitSchema Get /v1/open-platform/assets/submit-schema/{category_slug} دریافت قالب ثبت
ChatAPIAPI ChatAPIChatBotSendMessage Post /v1/open-platform/chat/bot/conversations/{conversation_id}/messages ارسال پیام به مکالمه ChatBot
ChatAPIAPI ChatAPIChatBotSendMessage2 Post /v1/open-platform/chat/bot/users/{user_id}/messages ارسال پیام به مکالمه ChatBot
ChatAPIAPI ChatAPIChatBotSendMessage3 Post /experimental/open-platform/chatbot-conversations/{conversation_id}/messages ارسال پیام به مکالمه ChatBot
ChatAPIAPI ChatAPIChatBotSendMessage4 Post /experimental/open-platform/chat/bot/users/{user_id}/messages ارسال پیام به مکالمه ChatBot
ChatAPIAPI ChatAPIChatBotSendMessage5 Post /experimental/open-platform/chat/bot/conversations/{conversation_id}/messages ارسال پیام به مکالمه ChatBot
ChatAPIAPI ChatAPIConversationSendMessage Post /v2/open-platform/conversations/{conversation_id}/messages ارسال پیام به مکالمه
ChatAPIAPI ChatAPIGenerateUploadToken Post /experimental/open-platform/chat/upload تولید توکن آپلود
ChatAPIAPI ChatAPIGetConversation Get /v1/open-platform/chat/conversations/{conversation_id} دریافت مکالمه با شناسه آن
EventsAPI EventsRegisterEventSubscription Post /v1/open-platform/events/subscriptions اشتراک در رویداد
EventsAPI EventsSendEvent Post /experimental/open-platform/events/send Send an event to a user
FinderAPI FinderGetPost Get /v1/open-platform/finder/post/{token} دریافت آگهی دیوار
FinderAPI FinderGetUser Post /v1/open-platform/users دریافت اطلاعات کاربر
FinderAPI FinderGetUser2 Get /v1/open-platform/users دریافت اطلاعات کاربر
FinderAPI FinderGetUserPosts Get /v1/open-platform/finder/user-posts دریافت آگهی‌های کاربر
FinderAPI FinderSearchPostV2 Post /v2/open-platform/finder/post جستجو آگهی‌های دیوار با فیلترهایی
LimitedAPI PaymentCommitWalletTransaction Post /experimental/open-platform/wallet/payments/commit
LimitedAPI PaymentCreateWalletPayment Post /experimental/open-platform/wallet/payments/create
LimitedAPI PaymentGetBalance Get /experimental/open-platform/balance
LimitedAPI PaymentGetPostPricing Get /v1/open-platform/post/{post_token}/pricing دریافت هزینه سرویس
LimitedAPI PaymentGetTransaction Get /experimental/open-platform/transactions/{id}
LimitedAPI PaymentListTransactions Get /experimental/open-platform/transactions
LimitedAPI PaymentReorderPost Post /experimental/open-platform/post/{post_token}/reorder
LimitedAPI PaymentRetrieveWalletTransaction Get /experimental/open-platform/wallet/payments/{token}
LimitedAPI PaymentSubmitUserPayment Post /v1/open-platform/user-payments Submit a user payment
PaymentTicketAPI PaymentTicketValidate Post /v1/open-platform/payment-ticket/validate اعتبارسنجی بلیط پرداخت
PostAPI PostEditPost Put /v1/open-platform/post/{post_token} ویرایش آگهی
PostAPI PostGetImageUploadURL Get /v1/open-platform/post/image-upload-url دریافت URL آپلود تصویر
PostAPI PostGetPostStats Get /experimental/open-platform/posts/{post_token}/stats دریافت آمارهای آگهی
PostAPI PostSubmitPost Post /experimental/open-platform/posts/new ثبت آگهی
PostAPI PostSubmitPostV2 Post /experimental/open-platform/posts/new-v2 ثبت آگهی با استفاده از اعتبارسنجی قالب JSON
PostAPI PostSubmitUserPost Post /experimental/open-platform/user-posts/new ثبت آگهی به عنوان کاربر
SemanticAPI SemanticCreatePostSemantic Post /experimental/open-platform/semantic/post/{token} ایجاد اطلاعات معنایی آگهی
SemanticAPI SemanticCreateUserSemantic Post /v1/open-platform/semantic/user/{phone} ایجاد اطلاعات معنایی کاربر
SemanticAPI SemanticCreateUserSemantic2 Post /v1/open-platform/semantic/users/{divar_user_id} ایجاد اطلاعات معنایی کاربر
SemanticAPI SemanticDeleteUserSemantic Delete /v1/open-platform/semantic/user/{phone} حذف اطلاعات معنایی کاربر
SemanticAPI SemanticDeleteUserSemantic2 Delete /v1/open-platform/semantic/users/{divar_user_id} حذف اطلاعات معنایی کاربر

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

APIKey

  • Type: API key
  • API key parameter name: X-API-Key
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: APIKey and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		kenarapi.ContextAPIKeys,
		map[string]kenarapi.APIKey{
			"APIKey": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

OAuth

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: oauth.divar.ir/oauth2/auth
  • Scopes:
  • BUSINESS_ADDON_CREATE.resource_id: BUSINESS_ADDON_CREATE.resource_id
  • CHAT_BOT_USER_MESSAGE_SEND: CHAT_BOT_USER_MESSAGE_SEND
  • CHAT_CONVERSATION_READ.resource_id: CHAT_CONVERSATION_READ.resource_id
  • CHAT_MESSAGE_SEND.resource_id: CHAT_MESSAGE_SEND.resource_id
  • CHAT_POST_CONVERSATIONS_MESSAGE_SEND.resource_id: CHAT_POST_CONVERSATIONS_MESSAGE_SEND.resource_id
  • CHAT_POST_CONVERSATIONS_READ.resource_id: CHAT_POST_CONVERSATIONS_READ.resource_id
  • CHAT_SUPPLIER_ALL_CONVERSATIONS_MESSAGE_SEND: CHAT_SUPPLIER_ALL_CONVERSATIONS_MESSAGE_SEND
  • CHAT_SUPPLIER_ALL_CONVERSATIONS_READ: CHAT_SUPPLIER_ALL_CONVERSATIONS_READ
  • CONVERSATION_SEND_MESSAGE.resource_id: CONVERSATION_SEND_MESSAGE.resource_id
  • MANAGEMENT_APPS_READ.resource_id: MANAGEMENT_APPS_READ.resource_id
  • MANAGEMENT_APPS_WRITE.resource_id: MANAGEMENT_APPS_WRITE.resource_id
  • NOTIFICATION_ACCESS_REVOCATION: NOTIFICATION_ACCESS_REVOCATION
  • PAYMENT_ALL_POSTS_PRICING_READ: PAYMENT_ALL_POSTS_PRICING_READ
  • PAYMENT_ALL_POSTS_REORDER: PAYMENT_ALL_POSTS_REORDER
  • POST_ADDON_CREATE.resource_id: POST_ADDON_CREATE.resource_id
  • POST_EDIT.resource_id: POST_EDIT.resource_id
  • POST_ONGOING_IMAGES_GET.resource_id: POST_ONGOING_IMAGES_GET.resource_id
  • POST_SEMANTIC_CREATE.resource_id: POST_SEMANTIC_CREATE.resource_id
  • USER_ADDON_CREATE: USER_ADDON_CREATE
  • USER_ID: USER_ID
  • USER_PHONE: USER_PHONE
  • USER_POSTS_ADDON_CREATE: USER_POSTS_ADDON_CREATE
  • USER_POSTS_GET: USER_POSTS_GET
  • USER_VERIFICATION_CREATE: USER_VERIFICATION_CREATE
  • offline_access: offline_access
  • openid: openid

Example

auth := context.WithValue(context.Background(), kenarapi.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, kenarapi.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages